liquor 0.1.1 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -9
- data/Gemfile +7 -0
- data/Guardfile +11 -0
- data/MIT-LICENSE +6 -2
- data/README.md +4 -122
- data/Rakefile +20 -23
- data/doc/language-spec.html +768 -0
- data/doc/language-spec.md +698 -0
- data/lib/liquor.rb +39 -68
- data/lib/liquor/ast_tools.rb +28 -0
- data/lib/liquor/compiler.rb +110 -0
- data/lib/liquor/context.rb +76 -254
- data/lib/liquor/diagnostics.rb +151 -0
- data/lib/liquor/drop/drop.rb +168 -0
- data/lib/liquor/drop/drop_delegation.rb +24 -0
- data/lib/liquor/drop/drop_scope.rb +118 -0
- data/lib/liquor/drop/dropable.rb +17 -0
- data/lib/liquor/emitter.rb +313 -0
- data/lib/liquor/extensions/kaminari.rb +14 -0
- data/lib/liquor/extensions/pagination.rb +235 -0
- data/lib/liquor/extensions/rails.rb +97 -0
- data/lib/liquor/extensions/thinking_sphinx.rb +14 -0
- data/lib/liquor/extensions/tire.rb +30 -0
- data/lib/liquor/external.rb +79 -0
- data/lib/liquor/function.rb +94 -0
- data/lib/liquor/grammar/lexer.rb +1223 -0
- data/lib/liquor/grammar/lexer.rl +297 -0
- data/lib/liquor/grammar/parser.racc +288 -0
- data/lib/liquor/grammar/parser.rb +885 -0
- data/lib/liquor/library.rb +41 -0
- data/lib/liquor/manager.rb +146 -0
- data/lib/liquor/runtime.rb +167 -0
- data/lib/liquor/stdlib/builtin_functions.rb +315 -0
- data/lib/liquor/stdlib/builtin_tags.rb +228 -0
- data/lib/liquor/stdlib/html_truncater.rb +162 -0
- data/lib/liquor/stdlib/partial_tags.rb +76 -0
- data/lib/liquor/tag.rb +83 -14
- data/lib/liquor/version.rb +1 -1
- data/liquor.gemspec +29 -6
- data/spec/builtins_spec.rb +264 -0
- data/spec/compiler_spec.rb +136 -0
- data/spec/context_spec.rb +49 -0
- data/spec/drop_delegation_spec.rb +21 -0
- data/spec/drop_spec.rb +222 -0
- data/spec/errors_spec.rb +40 -0
- data/spec/external_spec.rb +207 -0
- data/spec/function_spec.rb +80 -0
- data/spec/lexer_spec.rb +173 -0
- data/spec/library_spec.rb +18 -0
- data/spec/manager_spec.rb +84 -0
- data/spec/parser_spec.rb +381 -0
- data/spec/partials_spec.rb +74 -0
- data/spec/runtime_spec.rb +97 -0
- data/spec/spec_helper.rb +94 -0
- data/spec/tag_spec.rb +7 -0
- metadata +216 -173
- data/AUTHORS +0 -2
- data/CHANGELOG +0 -48
- data/Gemfile.lock +0 -91
- data/History.txt +0 -44
- data/LICENSE +0 -23
- data/example/server/example_servlet.rb +0 -37
- data/example/server/liquid_servlet.rb +0 -28
- data/example/server/liquor_servlet.rb +0 -28
- data/example/server/server.rb +0 -12
- data/example/server/templates/index.liquid +0 -6
- data/example/server/templates/index.liquor +0 -6
- data/example/server/templates/products.liquid +0 -45
- data/example/server/templates/products.liquor +0 -45
- data/init.rb +0 -8
- data/lib/extras/liquid_view.rb +0 -51
- data/lib/extras/liquor_view.rb +0 -51
- data/lib/liquor/block.rb +0 -101
- data/lib/liquor/condition.rb +0 -120
- data/lib/liquor/document.rb +0 -17
- data/lib/liquor/drop.rb +0 -256
- data/lib/liquor/errors.rb +0 -11
- data/lib/liquor/extensions.rb +0 -72
- data/lib/liquor/file_system.rb +0 -62
- data/lib/liquor/htmltags.rb +0 -74
- data/lib/liquor/module_ex.rb +0 -60
- data/lib/liquor/standardfilters.rb +0 -315
- data/lib/liquor/strainer.rb +0 -58
- data/lib/liquor/tags/assign.rb +0 -33
- data/lib/liquor/tags/capture.rb +0 -35
- data/lib/liquor/tags/case.rb +0 -83
- data/lib/liquor/tags/comment.rb +0 -9
- data/lib/liquor/tags/content_for.rb +0 -54
- data/lib/liquor/tags/cycle.rb +0 -59
- data/lib/liquor/tags/for.rb +0 -136
- data/lib/liquor/tags/if.rb +0 -80
- data/lib/liquor/tags/ifchanged.rb +0 -20
- data/lib/liquor/tags/include.rb +0 -56
- data/lib/liquor/tags/unless.rb +0 -33
- data/lib/liquor/tags/yield.rb +0 -49
- data/lib/liquor/template.rb +0 -181
- data/lib/liquor/variable.rb +0 -52
- data/performance/shopify.rb +0 -92
- data/performance/shopify/comment_form.rb +0 -33
- data/performance/shopify/database.rb +0 -45
- data/performance/shopify/json_filter.rb +0 -7
- data/performance/shopify/liquid.rb +0 -18
- data/performance/shopify/liquor.rb +0 -18
- data/performance/shopify/money_filter.rb +0 -18
- data/performance/shopify/paginate.rb +0 -93
- data/performance/shopify/shop_filter.rb +0 -98
- data/performance/shopify/tag_filter.rb +0 -25
- data/performance/shopify/vision.database.yml +0 -945
- data/performance/shopify/weight_filter.rb +0 -11
- data/performance/tests/dropify/article.liquid +0 -74
- data/performance/tests/dropify/blog.liquid +0 -33
- data/performance/tests/dropify/cart.liquid +0 -66
- data/performance/tests/dropify/collection.liquid +0 -22
- data/performance/tests/dropify/index.liquid +0 -47
- data/performance/tests/dropify/page.liquid +0 -8
- data/performance/tests/dropify/product.liquid +0 -68
- data/performance/tests/dropify/theme.liquid +0 -105
- data/performance/tests/ripen/article.liquid +0 -74
- data/performance/tests/ripen/blog.liquid +0 -13
- data/performance/tests/ripen/cart.liquid +0 -54
- data/performance/tests/ripen/collection.liquid +0 -29
- data/performance/tests/ripen/index.liquid +0 -32
- data/performance/tests/ripen/page.liquid +0 -4
- data/performance/tests/ripen/product.liquid +0 -75
- data/performance/tests/ripen/theme.liquid +0 -85
- data/performance/tests/tribble/404.liquid +0 -56
- data/performance/tests/tribble/article.liquid +0 -98
- data/performance/tests/tribble/blog.liquid +0 -41
- data/performance/tests/tribble/cart.liquid +0 -134
- data/performance/tests/tribble/collection.liquid +0 -70
- data/performance/tests/tribble/index.liquid +0 -94
- data/performance/tests/tribble/page.liquid +0 -56
- data/performance/tests/tribble/product.liquid +0 -116
- data/performance/tests/tribble/search.liquid +0 -51
- data/performance/tests/tribble/theme.liquid +0 -90
- data/performance/tests/vogue/article.liquid +0 -66
- data/performance/tests/vogue/blog.liquid +0 -32
- data/performance/tests/vogue/cart.liquid +0 -58
- data/performance/tests/vogue/collection.liquid +0 -19
- data/performance/tests/vogue/index.liquid +0 -22
- data/performance/tests/vogue/page.liquid +0 -3
- data/performance/tests/vogue/product.liquid +0 -62
- data/performance/tests/vogue/theme.liquid +0 -122
- data/test/assign_test.rb +0 -11
- data/test/block_test.rb +0 -58
- data/test/capture_test.rb +0 -41
- data/test/condition_test.rb +0 -115
- data/test/content_for_test.rb +0 -15
- data/test/context_test.rb +0 -479
- data/test/drop_test.rb +0 -162
- data/test/error_handling_test.rb +0 -89
- data/test/extra/breakpoint.rb +0 -547
- data/test/extra/caller.rb +0 -80
- data/test/file_system_test.rb +0 -30
- data/test/filter_test.rb +0 -147
- data/test/helper.rb +0 -24
- data/test/html_tag_test.rb +0 -31
- data/test/if_else_test.rb +0 -139
- data/test/include_tag_test.rb +0 -129
- data/test/module_ex_test.rb +0 -89
- data/test/output_test.rb +0 -121
- data/test/parsing_quirks_test.rb +0 -54
- data/test/regexp_test.rb +0 -45
- data/test/security_test.rb +0 -41
- data/test/standard_filter_test.rb +0 -170
- data/test/standard_tag_test.rb +0 -405
- data/test/statements_test.rb +0 -137
- data/test/strainer_test.rb +0 -27
- data/test/template_test.rb +0 -82
- data/test/test_helper.rb +0 -28
- data/test/unless_else_test.rb +0 -27
- data/test/variable_test.rb +0 -173
- data/test/yield_test.rb +0 -24
data/AUTHORS
DELETED
data/CHANGELOG
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
* Rails 3.2+ support [Ivan Evtukhovich, Timothy N. Tsvetkov]
|
2
|
-
|
3
|
-
* Forked and added powerful Drops with relations and some new tags. See more in docs [Timothy N. Tsvetkov]
|
4
|
-
|
5
|
-
* Ruby 1.9.1 bugfixes
|
6
|
-
|
7
|
-
* Fix LiquidView for Rails 2.2. Fix local assigns for all versions of Rails
|
8
|
-
|
9
|
-
* Fixed gem install rake task
|
10
|
-
* Improve Error encapsulation in liquid by maintaining a own set of exceptions instead of relying on ruby build ins
|
11
|
-
|
12
|
-
* Added If with or / and expressions
|
13
|
-
|
14
|
-
* Implemented .to_liquid for all objects which can be passed to liquid like Strings Arrays Hashes Numerics and Booleans. To export new objects to liquid just implement .to_liquid on them and return objects which themselves have .to_liquid methods.
|
15
|
-
|
16
|
-
* Added more tags to standard library
|
17
|
-
|
18
|
-
* Added include tag ( like partials in rails )
|
19
|
-
|
20
|
-
* [...] Gazillion of detail improvements
|
21
|
-
|
22
|
-
* Added strainers as filter hosts for better security [Tobias Luetke]
|
23
|
-
|
24
|
-
* Fixed that rails integration would call filter with the wrong "self" [Michael Geary]
|
25
|
-
|
26
|
-
* Fixed bad error reporting when a filter called a method which doesn't exist. Liquid told you that it couldn't find the filter which was obviously misleading [Tobias Luetke]
|
27
|
-
|
28
|
-
* Removed count helper from standard lib. use size [Tobias Luetke]
|
29
|
-
|
30
|
-
* Fixed bug with string filter parameters failing to tolerate commas in strings. [Paul Hammond]
|
31
|
-
|
32
|
-
* Improved filter parameters. Filter parameters are now context sensitive; Types are resolved according to the rules of the context. Multiple parameters are now separated by the Liquid::ArgumentSeparator: , by default [Paul Hammond]
|
33
|
-
|
34
|
-
{{ 'Typo' | link_to: 'http://typo.leetsoft.com', 'Typo - a modern weblog engine' }}
|
35
|
-
|
36
|
-
|
37
|
-
* Added Liquid::Drop. A base class which you can use for exporting proxy objects to liquid which can acquire more data when used in liquid. [Tobias Luetke]
|
38
|
-
|
39
|
-
class ProductDrop < Liquid::Drop
|
40
|
-
def top_sales
|
41
|
-
Shop.current.products.find(:all, :order => 'sales', :limit => 10 )
|
42
|
-
end
|
43
|
-
end
|
44
|
-
t = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {% endfor %} ' )
|
45
|
-
t.render('product' => ProductDrop.new )
|
46
|
-
|
47
|
-
|
48
|
-
* Added filter parameters support. Example: {{ date | format_date: "%Y" }} [Paul Hammond]
|
data/Gemfile.lock
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
liquor (0.1.1)
|
5
|
-
rails (~> 3.2.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actionmailer (3.2.3)
|
11
|
-
actionpack (= 3.2.3)
|
12
|
-
mail (~> 2.4.4)
|
13
|
-
actionpack (3.2.3)
|
14
|
-
activemodel (= 3.2.3)
|
15
|
-
activesupport (= 3.2.3)
|
16
|
-
builder (~> 3.0.0)
|
17
|
-
erubis (~> 2.7.0)
|
18
|
-
journey (~> 1.0.1)
|
19
|
-
rack (~> 1.4.0)
|
20
|
-
rack-cache (~> 1.2)
|
21
|
-
rack-test (~> 0.6.1)
|
22
|
-
sprockets (~> 2.1.2)
|
23
|
-
activemodel (3.2.3)
|
24
|
-
activesupport (= 3.2.3)
|
25
|
-
builder (~> 3.0.0)
|
26
|
-
activerecord (3.2.3)
|
27
|
-
activemodel (= 3.2.3)
|
28
|
-
activesupport (= 3.2.3)
|
29
|
-
arel (~> 3.0.2)
|
30
|
-
tzinfo (~> 0.3.29)
|
31
|
-
activeresource (3.2.3)
|
32
|
-
activemodel (= 3.2.3)
|
33
|
-
activesupport (= 3.2.3)
|
34
|
-
activesupport (3.2.3)
|
35
|
-
i18n (~> 0.6)
|
36
|
-
multi_json (~> 1.0)
|
37
|
-
arel (3.0.2)
|
38
|
-
builder (3.0.0)
|
39
|
-
erubis (2.7.0)
|
40
|
-
hike (1.2.1)
|
41
|
-
i18n (0.6.0)
|
42
|
-
journey (1.0.3)
|
43
|
-
json (1.7.1)
|
44
|
-
mail (2.4.4)
|
45
|
-
i18n (>= 0.4.0)
|
46
|
-
mime-types (~> 1.16)
|
47
|
-
treetop (~> 1.4.8)
|
48
|
-
mime-types (1.18)
|
49
|
-
multi_json (1.3.4)
|
50
|
-
polyglot (0.3.3)
|
51
|
-
rack (1.4.1)
|
52
|
-
rack-cache (1.2)
|
53
|
-
rack (>= 0.4)
|
54
|
-
rack-ssl (1.3.2)
|
55
|
-
rack
|
56
|
-
rack-test (0.6.1)
|
57
|
-
rack (>= 1.0)
|
58
|
-
rails (3.2.3)
|
59
|
-
actionmailer (= 3.2.3)
|
60
|
-
actionpack (= 3.2.3)
|
61
|
-
activerecord (= 3.2.3)
|
62
|
-
activeresource (= 3.2.3)
|
63
|
-
activesupport (= 3.2.3)
|
64
|
-
bundler (~> 1.0)
|
65
|
-
railties (= 3.2.3)
|
66
|
-
railties (3.2.3)
|
67
|
-
actionpack (= 3.2.3)
|
68
|
-
activesupport (= 3.2.3)
|
69
|
-
rack-ssl (~> 1.3.2)
|
70
|
-
rake (>= 0.8.7)
|
71
|
-
rdoc (~> 3.4)
|
72
|
-
thor (~> 0.14.6)
|
73
|
-
rake (0.9.2.2)
|
74
|
-
rdoc (3.12)
|
75
|
-
json (~> 1.4)
|
76
|
-
sprockets (2.1.3)
|
77
|
-
hike (~> 1.2)
|
78
|
-
rack (~> 1.0)
|
79
|
-
tilt (~> 1.1, != 1.3.0)
|
80
|
-
thor (0.14.6)
|
81
|
-
tilt (1.3.3)
|
82
|
-
treetop (1.4.10)
|
83
|
-
polyglot
|
84
|
-
polyglot (>= 0.3.1)
|
85
|
-
tzinfo (0.3.33)
|
86
|
-
|
87
|
-
PLATFORMS
|
88
|
-
ruby
|
89
|
-
|
90
|
-
DEPENDENCIES
|
91
|
-
liquor!
|
data/History.txt
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
1.9.0 / 2008-03-04
|
2
|
-
|
3
|
-
* Fixed gem install rake task
|
4
|
-
* Improve Error encapsulation in liquid by maintaining a own set of exceptions instead of relying on ruby build ins
|
5
|
-
|
6
|
-
Before 1.9.0
|
7
|
-
|
8
|
-
* Added If with or / and expressions
|
9
|
-
|
10
|
-
* Implemented .to_liquid for all objects which can be passed to liquid like Strings Arrays Hashes Numerics and Booleans. To export new objects to liquid just implement .to_liquid on them and return objects which themselves have .to_liquid methods.
|
11
|
-
|
12
|
-
* Added more tags to standard library
|
13
|
-
|
14
|
-
* Added include tag ( like partials in rails )
|
15
|
-
|
16
|
-
* [...] Gazillion of detail improvements
|
17
|
-
|
18
|
-
* Added strainers as filter hosts for better security [Tobias Luetke]
|
19
|
-
|
20
|
-
* Fixed that rails integration would call filter with the wrong "self" [Michael Geary]
|
21
|
-
|
22
|
-
* Fixed bad error reporting when a filter called a method which doesn't exist. Liquid told you that it couldn't find the filter which was obviously misleading [Tobias Luetke]
|
23
|
-
|
24
|
-
* Removed count helper from standard lib. use size [Tobias Luetke]
|
25
|
-
|
26
|
-
* Fixed bug with string filter parameters failing to tolerate commas in strings. [Paul Hammond]
|
27
|
-
|
28
|
-
* Improved filter parameters. Filter parameters are now context sensitive; Types are resolved according to the rules of the context. Multiple parameters are now separated by the Liquid::ArgumentSeparator: , by default [Paul Hammond]
|
29
|
-
|
30
|
-
{{ 'Typo' | link_to: 'http://typo.leetsoft.com', 'Typo - a modern weblog engine' }}
|
31
|
-
|
32
|
-
|
33
|
-
* Added Liquid::Drop. A base class which you can use for exporting proxy objects to liquid which can acquire more data when used in liquid. [Tobias Luetke]
|
34
|
-
|
35
|
-
class ProductDrop < Liquid::Drop
|
36
|
-
def top_sales
|
37
|
-
Shop.current.products.find(:all, :order => 'sales', :limit => 10 )
|
38
|
-
end
|
39
|
-
end
|
40
|
-
t = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {% endfor %} ' )
|
41
|
-
t.render('product' => ProductDrop.new )
|
42
|
-
|
43
|
-
|
44
|
-
* Added filter parameters support. Example: {{ date | format_date: "%Y" }} [Paul Hammond]
|
data/LICENSE
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
Copyright (c) 2005, 2006 Tobias Luetke
|
2
|
-
Copyright (c) Timothy N. Tsvetkov
|
3
|
-
|
4
|
-
MIT License
|
5
|
-
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
-
a copy of this software and associated documentation files (the
|
8
|
-
"Software"), to deal in the Software without restriction, including
|
9
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
-
permit persons to whom the Software is furnished to do so, subject to
|
12
|
-
the following conditions:
|
13
|
-
|
14
|
-
The above copyright notice and this permission notice shall be
|
15
|
-
included in all copies or substantial portions of the Software.
|
16
|
-
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module ProductsFilter
|
2
|
-
def price(integer)
|
3
|
-
sprintf("$%.2d USD", integer / 100.0)
|
4
|
-
end
|
5
|
-
|
6
|
-
def prettyprint(text)
|
7
|
-
text.gsub( /\*(.*)\*/, '<b>\1</b>' )
|
8
|
-
end
|
9
|
-
|
10
|
-
def count(array)
|
11
|
-
array.size
|
12
|
-
end
|
13
|
-
|
14
|
-
def paragraph(p)
|
15
|
-
"<p>#{p}</p>"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class Servlet < LiquidServlet
|
20
|
-
|
21
|
-
def index
|
22
|
-
{ 'date' => Time.now }
|
23
|
-
end
|
24
|
-
|
25
|
-
def products
|
26
|
-
{ 'products' => products_list, 'section' => 'Snowboards', 'cool_products' => true}
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def products_list
|
32
|
-
[{'name' => 'Arbor Draft', 'price' => 39900, 'description' => 'the *arbor draft* is a excellent product' },
|
33
|
-
{'name' => 'Arbor Element', 'price' => 40000, 'description' => 'the *arbor element* rocks for freestyling'},
|
34
|
-
{'name' => 'Arbor Diamond', 'price' => 59900, 'description' => 'the *arbor diamond* is a made up product because im obsessed with arbor and have no creativity'}]
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
class LiquidServlet < WEBrick::HTTPServlet::AbstractServlet
|
2
|
-
|
3
|
-
def do_GET(req, res)
|
4
|
-
handle(:get, req, res)
|
5
|
-
end
|
6
|
-
|
7
|
-
def do_POST(req, res)
|
8
|
-
handle(:post, req, res)
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def handle(type, req, res)
|
14
|
-
@request, @response = req, res
|
15
|
-
|
16
|
-
@request.path_info =~ /(\w+)$/
|
17
|
-
@action = $1 || 'index'
|
18
|
-
@assigns = send(@action) if respond_to?(@action)
|
19
|
-
|
20
|
-
@response['Content-Type'] = "text/html"
|
21
|
-
@response.status = 200
|
22
|
-
@response.body = Liquid::Template.parse(read_template).render(@assigns, :filters => [ProductsFilter])
|
23
|
-
end
|
24
|
-
|
25
|
-
def read_template(filename = @action)
|
26
|
-
File.read( File.dirname(__FILE__) + "/templates/#{filename}.liquid" )
|
27
|
-
end
|
28
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
class LiquorServlet < WEBrick::HTTPServlet::AbstractServlet
|
2
|
-
|
3
|
-
def do_GET(req, res)
|
4
|
-
handle(:get, req, res)
|
5
|
-
end
|
6
|
-
|
7
|
-
def do_POST(req, res)
|
8
|
-
handle(:post, req, res)
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def handle(type, req, res)
|
14
|
-
@request, @response = req, res
|
15
|
-
|
16
|
-
@request.path_info =~ /(\w+)$/
|
17
|
-
@action = $1 || 'index'
|
18
|
-
@assigns = send(@action) if respond_to?(@action)
|
19
|
-
|
20
|
-
@response['Content-Type'] = "text/html"
|
21
|
-
@response.status = 200
|
22
|
-
@response.body = Liquor::Template.parse(read_template).render(@assigns, :filters => [ProductsFilter])
|
23
|
-
end
|
24
|
-
|
25
|
-
def read_template(filename = @action)
|
26
|
-
File.read( File.dirname(__FILE__) + "/templates/#{filename}.liquor" )
|
27
|
-
end
|
28
|
-
end
|
data/example/server/server.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'webrick'
|
2
|
-
require 'rexml/document'
|
3
|
-
|
4
|
-
require File.dirname(__FILE__) + '/../../lib/liquor'
|
5
|
-
require File.dirname(__FILE__) + '/liquor_servlet'
|
6
|
-
require File.dirname(__FILE__) + '/example_servlet'
|
7
|
-
|
8
|
-
# Setup webrick
|
9
|
-
server = WEBrick::HTTPServer.new( :Port => ARGV[1] || 3000 )
|
10
|
-
server.mount('/', Servlet)
|
11
|
-
trap("INT"){ server.shutdown }
|
12
|
-
server.start
|
@@ -1,45 +0,0 @@
|
|
1
|
-
<?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">
|
4
|
-
<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>There are currently {{products | count}} products in the {{section}} catalog</h1>
|
21
|
-
|
22
|
-
{% if cool_products %}
|
23
|
-
Cool products :)
|
24
|
-
{% else %}
|
25
|
-
Uncool products :(
|
26
|
-
{% endif %}
|
27
|
-
|
28
|
-
<ul id="products">
|
29
|
-
|
30
|
-
{% for product in products %}
|
31
|
-
<li>
|
32
|
-
<h2>{{product.name}}</h2>
|
33
|
-
Only {{product.price | price }}
|
34
|
-
|
35
|
-
{{product.description | prettyprint | paragraph }}
|
36
|
-
|
37
|
-
{{ 'it rocks!' | paragraph }}
|
38
|
-
|
39
|
-
</li>
|
40
|
-
{% endfor %}
|
41
|
-
|
42
|
-
</ul>
|
43
|
-
|
44
|
-
</body>
|
45
|
-
</html>
|
@@ -1,45 +0,0 @@
|
|
1
|
-
<?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">
|
4
|
-
<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>There are currently {{products | count}} products in the {{section}} catalog</h1>
|
21
|
-
|
22
|
-
{% if cool_products %}
|
23
|
-
Cool products :)
|
24
|
-
{% else %}
|
25
|
-
Uncool products :(
|
26
|
-
{% endif %}
|
27
|
-
|
28
|
-
<ul id="products">
|
29
|
-
|
30
|
-
{% for product in products %}
|
31
|
-
<li>
|
32
|
-
<h2>{{product.name}}</h2>
|
33
|
-
Only {{product.price | price }}
|
34
|
-
|
35
|
-
{{product.description | prettyprint | paragraph }}
|
36
|
-
|
37
|
-
{{ 'it rocks!' | paragraph }}
|
38
|
-
|
39
|
-
</li>
|
40
|
-
{% endfor %}
|
41
|
-
|
42
|
-
</ul>
|
43
|
-
|
44
|
-
</body>
|
45
|
-
</html>
|
data/init.rb
DELETED
data/lib/extras/liquid_view.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# LiquidView is a action view extension class. You can register it with rails
|
2
|
-
# and use liquid as an template system for .liquid files
|
3
|
-
#
|
4
|
-
# Example
|
5
|
-
#
|
6
|
-
# ActionView::Base::register_template_handler :liquid, LiquidView
|
7
|
-
class LiquidView
|
8
|
-
PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
|
9
|
-
_response url _request _cookies variables_added _flash params _headers request cookies
|
10
|
-
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
|
12
|
-
@helpers @assigns_added @template @_render_stack @template_format @assigns )
|
13
|
-
|
14
|
-
def self.call(template)
|
15
|
-
"LiquidView.new(self).render(template, local_assigns)"
|
16
|
-
end
|
17
|
-
|
18
|
-
def initialize(view)
|
19
|
-
@view = view
|
20
|
-
end
|
21
|
-
|
22
|
-
def render(template, local_assigns = nil)
|
23
|
-
@view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
|
24
|
-
|
25
|
-
# Rails 2.2 Template has source, but not locals
|
26
|
-
if template.respond_to?(:source) && !template.respond_to?(:locals)
|
27
|
-
assigns = (@view.instance_variables - PROTECTED_INSTANCE_VARIABLES).inject({}) do |hash, ivar|
|
28
|
-
hash[ivar[1..-1]] = @view.instance_variable_get(ivar)
|
29
|
-
hash
|
30
|
-
end
|
31
|
-
else
|
32
|
-
assigns = @view.assigns.reject{ |k,v| PROTECTED_ASSIGNS.include?(k) }
|
33
|
-
end
|
34
|
-
|
35
|
-
source = template.respond_to?(:source) ? template.source : template
|
36
|
-
local_assigns = (template.respond_to?(:locals) ? template.locals : local_assigns) || {}
|
37
|
-
|
38
|
-
if content_for_layout = @view.instance_variable_get("@content_for_layout")
|
39
|
-
assigns['content_for_layout'] = content_for_layout
|
40
|
-
end
|
41
|
-
assigns.merge!(local_assigns.stringify_keys)
|
42
|
-
|
43
|
-
liquid = Liquid::Template.parse(source)
|
44
|
-
liquid.render(assigns, :filters => [@view.controller.master_helper_module], :registers => {:action_view => @view, :controller => @view.controller})
|
45
|
-
end
|
46
|
-
|
47
|
-
def compilable?
|
48
|
-
false
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|