Class: Cutaneous::Template
- Inherits:
-
Object
- Object
- Cutaneous::Template
- Defined in:
- lib/cutaneous/template.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#lexer ⇒ Object
Returns the value of attribute lexer.
-
#loader ⇒ Object
Returns the value of attribute loader.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #block(block_name) ⇒ Object
- #block_order ⇒ Object
- #compiler ⇒ Object
- #convert(to_syntax) ⇒ Object
-
#initialize(lexer) ⇒ Template
constructor
A new instance of Template.
- #render(context) ⇒ Object
- #script ⇒ Object
- #template_proc ⇒ Object
- #template_proc_src ⇒ Object
Constructor Details
#initialize(lexer) ⇒ Template
Returns a new instance of Template.
6 7 8 |
# File 'lib/cutaneous/template.rb', line 6 def initialize(lexer) @lexer = lexer end |
Instance Attribute Details
#lexer ⇒ Object
Returns the value of attribute lexer.
4 5 6 |
# File 'lib/cutaneous/template.rb', line 4 def lexer @lexer end |
#loader ⇒ Object
Returns the value of attribute loader.
4 5 6 |
# File 'lib/cutaneous/template.rb', line 4 def loader @loader end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/cutaneous/template.rb', line 4 def path @path end |
Instance Method Details
#block(block_name) ⇒ Object
39 40 41 |
# File 'lib/cutaneous/template.rb', line 39 def block(block_name) compiler.block(block_name) end |
#block_order ⇒ Object
35 36 37 |
# File 'lib/cutaneous/template.rb', line 35 def block_order compiler.block_order end |
#compiler ⇒ Object
10 11 12 |
# File 'lib/cutaneous/template.rb', line 10 def compiler @compiler ||= Compiler.new(lexer, loader) end |
#convert(to_syntax) ⇒ Object
19 20 21 |
# File 'lib/cutaneous/template.rb', line 19 def convert(to_syntax) lexer.convert(to_syntax) end |
#render(context) ⇒ Object
14 15 16 17 |
# File 'lib/cutaneous/template.rb', line 14 def render(context) context.__loader = loader context.instance_eval(&template_proc) end |
#script ⇒ Object
31 32 33 |
# File 'lib/cutaneous/template.rb', line 31 def script compiler.script end |
#template_proc ⇒ Object
23 24 25 |
# File 'lib/cutaneous/template.rb', line 23 def template_proc @template_proc ||= eval(template_proc_src, nil, path || "(cutaneous)") end |
#template_proc_src ⇒ Object
27 28 29 |
# File 'lib/cutaneous/template.rb', line 27 def template_proc_src "lambda { |context| self.__buf = __buf = ''; #{script}; __buf.to_s }" end |