Class: Rapid::Template::Base
- Inherits:
-
Object
- Object
- Rapid::Template::Base
- Defined in:
- lib/rapid/template/base.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
-
#initialize(content, options = {}) ⇒ Base
constructor
A new instance of Base.
- #pull(content) ⇒ Object
- #push(skeleton) ⇒ Object
Constructor Details
#initialize(content, options = {}) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 |
# File 'lib/rapid/template/base.rb', line 8 def initialize content, = {} @content = polish_content content @filename = [:filename] @erb = Erubis::Eruby.new @content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/rapid/template/base.rb', line 6 def content @content end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
6 7 8 |
# File 'lib/rapid/template/base.rb', line 6 def filename @filename end |
Instance Method Details
#pull(content) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rapid/template/base.rb', line 21 def pull content content = polish_content content nodes = Parser.new(@content).parse result = Pulling::Forgiving.new(content) nodes.pull result result.empty! result.to_hash end |
#push(skeleton) ⇒ Object
15 16 17 18 19 |
# File 'lib/rapid/template/base.rb', line 15 def push skeleton @erb.result skeleton.get_binding rescue Exception, SyntaxError, NameError => e raise TemplateRenderError.new(@filename, e) end |