tobi-liquid 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ module Liquid
2
+
3
+ # Holds variables. Variables are only loaded "just in time"
4
+ # and are not evaluated as part of the render stage
5
+ #
6
+ # {{ monkey }}
7
+ # {{ user.name }}
8
+ #
9
+ # Variables can be combined with filters:
10
+ #
11
+ # {{ user | link }}
12
+ #
13
+ class Variable
14
+ attr_accessor :filters, :name
15
+
16
+ def initialize(markup)
17
+ @markup = markup
18
+ @name = nil
19
+ @filters = []
20
+ if match = markup.match(/\s*(#{QuotedFragment})/)
21
+ @name = match[1]
22
+ if markup.match(/#{FilterSeparator}\s*(.*)/)
23
+ filters = Regexp.last_match(1).split(/#{FilterSeparator}/)
24
+ filters.each do |f|
25
+ if matches = f.match(/\s*(\w+)/)
26
+ filtername = matches[1]
27
+ filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*(#{QuotedFragment})/).flatten
28
+ @filters << [filtername.to_sym, filterargs]
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ def render(context)
36
+ return '' if @name.nil?
37
+ @filters.inject(context[@name]) do |output, filter|
38
+ filterargs = filter[1].to_a.collect do |a|
39
+ context[a]
40
+ end
41
+ begin
42
+ output = context.invoke(filter[0], output, *filterargs)
43
+ rescue FilterNotFound
44
+ raise FilterNotFound, "Error - filter '#{filter[0]}' in '#{@markup.strip}' could not be found."
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tobi-liquid
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tobias Luetke
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-04-13 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A secure non evaling end user template engine with aesthetic markup.
17
+ email: tobi@leetsoft.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - History.txt
24
+ - Manifest.txt
25
+ - README.txt
26
+ files:
27
+ - CHANGELOG
28
+ - History.txt
29
+ - MIT-LICENSE
30
+ - Manifest.txt
31
+ - README.txt
32
+ - Rakefile
33
+ - lib/extras/liquid_view.rb
34
+ - lib/liquid.rb
35
+ - lib/liquid/block.rb
36
+ - lib/liquid/condition.rb
37
+ - lib/liquid/context.rb
38
+ - lib/liquid/document.rb
39
+ - lib/liquid/drop.rb
40
+ - lib/liquid/errors.rb
41
+ - lib/liquid/extensions.rb
42
+ - lib/liquid/file_system.rb
43
+ - lib/liquid/htmltags.rb
44
+ - lib/liquid/module_ex.rb
45
+ - lib/liquid/standardfilters.rb
46
+ - lib/liquid/strainer.rb
47
+ - lib/liquid/tag.rb
48
+ - lib/liquid/tags/assign.rb
49
+ - lib/liquid/tags/capture.rb
50
+ - lib/liquid/tags/case.rb
51
+ - lib/liquid/tags/comment.rb
52
+ - lib/liquid/tags/cycle.rb
53
+ - lib/liquid/tags/for.rb
54
+ - lib/liquid/tags/if.rb
55
+ - lib/liquid/tags/ifchanged.rb
56
+ - lib/liquid/tags/include.rb
57
+ - lib/liquid/tags/unless.rb
58
+ - lib/liquid/template.rb
59
+ - lib/liquid/variable.rb
60
+ has_rdoc: true
61
+ homepage: http://www.liquidmarkup.org
62
+ post_install_message:
63
+ rdoc_options:
64
+ - --main
65
+ - README.txt
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project: liquid
83
+ rubygems_version: 1.2.0
84
+ signing_key:
85
+ specification_version: 2
86
+ summary: A secure non evaling end user template engine with aesthetic markup.
87
+ test_files: []
88
+