Skip to content

Commit 0f5441b

Browse files
author
Florian Weingarten
committed
Convert legacy tab indentation to spaces and remove trailing whitespace from all lines
1 parent 7a3746a commit 0f5441b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1952
-1952
lines changed

Diff for: MIT-LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1717
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1818
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1919
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Diff for: example/server/example_servlet.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,40 @@ module ProductsFilter
22
def price(integer)
33
sprintf("$%.2d USD", integer / 100.0)
44
end
5-
5+
66
def prettyprint(text)
77
text.gsub( /\*(.*)\*/, '<b>\1</b>' )
88
end
9-
9+
1010
def count(array)
1111
array.size
1212
end
13-
13+
1414
def paragraph(p)
1515
"<p>#{p}</p>"
1616
end
1717
end
1818

1919
class Servlet < LiquidServlet
20-
20+
2121
def index
2222
{ 'date' => Time.now }
2323
end
24-
25-
def products
26-
{ 'products' => products_list, 'description' => description, 'section' => 'Snowboards', 'cool_products' => true}
24+
25+
def products
26+
{ 'products' => products_list, 'description' => description, 'section' => 'Snowboards', 'cool_products' => true}
2727
end
2828

2929
private
30-
30+
3131
def products_list
3232
[{'name' => 'Arbor Draft', 'price' => 39900, 'description' => 'the *arbor draft* is a excellent product' },
3333
{'name' => 'Arbor Element', 'price' => 40000, 'description' => 'the *arbor element* rocks for freestyling'},
3434
{'name' => 'Arbor Diamond', 'price' => 59900, 'description' => 'the *arbor diamond* is a made up product because im obsessed with arbor and have no creativity'}]
3535
end
36-
36+
3737
def description
3838
"List of Products ~ This is a list of products with price and description."
3939
end
40-
40+
4141
end

Diff for: example/server/liquid_servlet.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ def do_GET(req, res)
77
def do_POST(req, res)
88
handle(:post, req, res)
99
end
10-
10+
1111
private
12-
12+
1313
def handle(type, req, res)
1414
@request, @response = req, res
15-
15+
1616
@request.path_info =~ /(\w+)$/
17-
@action = $1 || 'index'
18-
@assigns = send(@action) if respond_to?(@action)
17+
@action = $1 || 'index'
18+
@assigns = send(@action) if respond_to?(@action)
1919

2020
@response['Content-Type'] = "text/html"
2121
@response.status = 200
22-
@response.body = Liquid::Template.parse(read_template).render(@assigns, :filters => [ProductsFilter])
22+
@response.body = Liquid::Template.parse(read_template).render(@assigns, :filters => [ProductsFilter])
2323
end
24-
24+
2525
def read_template(filename = @action)
2626
File.read( File.dirname(__FILE__) + "/templates/#{filename}.liquid" )
2727
end
28-
end
28+
end

Diff for: example/server/templates/index.liquid

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<p>It is {{date}}</p>
44

55

6-
<p>Check out the <a href="http://localhost:3000/products">Products</a> screen </p>
6+
<p>Check out the <a href="http://localhost:3000/products">Products</a> screen </p>

Diff for: example/server/templates/products.liquid

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
44
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5-
<head>
6-
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
7-
<meta http-equiv="Content-Language" content="en-us" />
8-
9-
<title>products</title>
10-
11-
<meta name="ROBOTS" content="ALL" />
12-
<meta http-equiv="imagetoolbar" content="no" />
13-
<meta name="MSSmartTagsPreventParsing" content="true" />
14-
<meta name="Copyright" content="(c) 2005 Copyright content: Copyright design: Tobias Luetke" />
15-
<!-- (c) Copyright 2005 by Tobias Luetke All Rights Reserved. -->
16-
</head>
17-
18-
<body>
19-
20-
<h1>{{ description | split: '~' | first }}</h1>
21-
22-
<h2>{{ description | split: '~' | last }}</h2>
23-
24-
<h2>There are currently {{products | count}} products in the {{section}} catalog</h2>
5+
<head>
6+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
7+
<meta http-equiv="Content-Language" content="en-us" />
8+
9+
<title>products</title>
10+
11+
<meta name="ROBOTS" content="ALL" />
12+
<meta http-equiv="imagetoolbar" content="no" />
13+
<meta name="MSSmartTagsPreventParsing" content="true" />
14+
<meta name="Copyright" content="(c) 2005 Copyright content: Copyright design: Tobias Luetke" />
15+
<!-- (c) Copyright 2005 by Tobias Luetke All Rights Reserved. -->
16+
</head>
17+
18+
<body>
19+
20+
<h1>{{ description | split: '~' | first }}</h1>
21+
22+
<h2>{{ description | split: '~' | last }}</h2>
23+
24+
<h2>There are currently {{products | count}} products in the {{section}} catalog</h2>
2525

2626
{% if cool_products %}
27-
Cool products :)
27+
Cool products :)
2828
{% else %}
29-
Uncool products :(
29+
Uncool products :(
3030
{% endif %}
3131

3232
<ul id="products">
33-
33+
3434
{% for product in products %}
3535
<li>
3636
<h2>{{product.name}}</h2>
3737
Only {{product.price | price }}
38-
38+
3939
{{product.description | prettyprint | paragraph }}
40-
40+
4141
{{ 'it rocks!' | paragraph }}
42-
43-
</li>
42+
43+
</li>
4444
{% endfor %}
45-
45+
4646
</ul>
47-
48-
</body>
47+
48+
</body>
4949
</html>

Diff for: lib/extras/liquid_view.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
# and use liquid as an template system for .liquid files
33
#
44
# Example
5-
#
5+
#
66
# ActionView::Base::register_template_handler :liquid, LiquidView
77
class LiquidView
88
PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
99
_response url _request _cookies variables_added _flash params _headers request cookies
1010
ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
11-
PROTECTED_INSTANCE_VARIABLES = %w( @_request @controller @_first_render @_memoized__pick_template @view_paths
11+
PROTECTED_INSTANCE_VARIABLES = %w( @_request @controller @_first_render @_memoized__pick_template @view_paths
1212
@helpers @assigns_added @template @_render_stack @template_format @assigns )
13-
13+
1414
def self.call(template)
1515
"LiquidView.new(self).render(template, local_assigns)"
1616
end
1717

1818
def initialize(view)
1919
@view = view
2020
end
21-
21+
2222
def render(template, local_assigns = nil)
2323
@view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
24-
24+
2525
# Rails 2.2 Template has source, but not locals
2626
if template.respond_to?(:source) && !template.respond_to?(:locals)
2727
assigns = (@view.instance_variables - PROTECTED_INSTANCE_VARIABLES).inject({}) do |hash, ivar|
@@ -31,15 +31,15 @@ def render(template, local_assigns = nil)
3131
else
3232
assigns = @view.assigns.reject{ |k,v| PROTECTED_ASSIGNS.include?(k) }
3333
end
34-
34+
3535
source = template.respond_to?(:source) ? template.source : template
3636
local_assigns = (template.respond_to?(:locals) ? template.locals : local_assigns) || {}
37-
37+
3838
if content_for_layout = @view.instance_variable_get("@content_for_layout")
3939
assigns['content_for_layout'] = content_for_layout
4040
end
4141
assigns.merge!(local_assigns.stringify_keys)
42-
42+
4343
liquid = Liquid::Template.parse(source)
4444
liquid.render(assigns, :filters => [@view.controller.master_helper_module], :registers => {:action_view => @view, :controller => @view.controller})
4545
end
@@ -48,4 +48,4 @@ def compilable?
4848
false
4949
end
5050

51-
end
51+
end

Diff for: lib/liquid/block.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def render_all(list, context)
9999

100100
begin
101101
# If we get an Interrupt that means the block must stop processing. An
102-
# Interrupt is any command that stops block execution such as {% break %}
102+
# Interrupt is any command that stops block execution such as {% break %}
103103
# or {% continue %}
104104
if token.is_a? Continue or token.is_a? Break
105105
context.push_interrupt(token.interrupt)

Diff for: lib/liquid/file_system.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Liquid
22
# A Liquid file system is way to let your templates retrieve other templates for use with the include tag.
33
#
4-
# You can implement subclasses that retrieve templates from the database, from the file system using a different
4+
# You can implement subclasses that retrieve templates from the database, from the file system using a different
55
# path structure, you can provide them as hard-coded inline strings, or any manner that you see fit.
66
#
77
# You can add additional instance variables, arguments, or methods as needed.
@@ -18,7 +18,7 @@ def read_template_file(template_path, context)
1818
raise FileSystemError, "This liquid context does not allow includes."
1919
end
2020
end
21-
21+
2222
# This implements an abstract file system which retrieves template files named in a manner similar to Rails partials,
2323
# ie. with the template name prefixed with an underscore. The extension ".liquid" is also added.
2424
#
@@ -27,36 +27,36 @@ def read_template_file(template_path, context)
2727
# Example:
2828
#
2929
# file_system = Liquid::LocalFileSystem.new("/some/path")
30-
#
30+
#
3131
# file_system.full_path("mypartial") # => "/some/path/_mypartial.liquid"
3232
# file_system.full_path("dir/mypartial") # => "/some/path/dir/_mypartial.liquid"
3333
#
3434
class LocalFileSystem
3535
attr_accessor :root
36-
36+
3737
def initialize(root)
3838
@root = root
3939
end
40-
40+
4141
def read_template_file(template_path, context)
4242
full_path = full_path(template_path)
4343
raise FileSystemError, "No such template '#{template_path}'" unless File.exists?(full_path)
44-
44+
4545
File.read(full_path)
4646
end
47-
47+
4848
def full_path(template_path)
4949
raise FileSystemError, "Illegal template name '#{template_path}'" unless template_path =~ /^[^.\/][a-zA-Z0-9_\/]+$/
50-
50+
5151
full_path = if template_path.include?('/')
5252
File.join(root, File.dirname(template_path), "_#{File.basename(template_path)}.liquid")
5353
else
5454
File.join(root, "_#{template_path}.liquid")
5555
end
56-
56+
5757
raise FileSystemError, "Illegal template path '#{File.expand_path(full_path)}'" unless File.expand_path(full_path) =~ /^#{File.expand_path(root)}/
58-
58+
5959
full_path
6060
end
6161
end
62-
end
62+
end

Diff for: lib/liquid/tags/assign.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ module Liquid
1010
#
1111
class Assign < Tag
1212
Syntax = /(#{VariableSignature}+)\s*=\s*(.*)\s*/o
13-
14-
def initialize(tag_name, markup, tokens)
13+
14+
def initialize(tag_name, markup, tokens)
1515
if markup =~ Syntax
1616
@to = $1
1717
@from = Variable.new($2)
1818
else
1919
raise SyntaxError.new("Syntax Error in 'assign' - Valid syntax: assign [var] = [source]")
2020
end
21-
22-
super
21+
22+
super
2323
end
24-
24+
2525
def render(context)
2626
val = @from.render(context)
2727
context.scopes.last[@to] = val
2828
context.resource_limits[:assign_score_current] += (val.respond_to?(:length) ? val.length : 1)
2929
''
30-
end
31-
32-
end
33-
34-
Template.register_tag('assign', Assign)
30+
end
31+
32+
end
33+
34+
Template.register_tag('assign', Assign)
3535
end

Diff for: lib/liquid/tags/break.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module Liquid
88
# {% break %}
99
# {% endif %}
1010
# {% endfor %}
11-
#
12-
class Break < Tag
11+
#
12+
class Break < Tag
1313

1414
def interrupt
1515
BreakInterrupt.new

0 commit comments

Comments
 (0)