Class: PORTL::Engine
- Inherits:
-
Object
- Object
- PORTL::Engine
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- lib/portl/engine.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#html_tag(tag, *args, &block) ⇒ Object
Creates an HTML tag.
-
#initialize(data, scope = nil, options = {}) ⇒ Engine
constructor
A new instance of Engine.
-
#result ⇒ String
Compiles the data within the supplied scope and returns the result.
-
#text(value) ⇒ ActionView::OutputBuffer
Adds plain text to the output buffer.
Constructor Details
#initialize(data, scope = nil, options = {}) ⇒ Engine
Returns a new instance of Engine.
8 9 10 11 12 13 |
# File 'lib/portl/engine.rb', line 8 def initialize(data, scope=nil, ={}) @data = data @scope = scope @options = @output_buffer = ActionView::OutputBuffer.new end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/portl/engine.rb', line 4 def data @data end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/portl/engine.rb', line 4 def @options end |
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
6 7 8 |
# File 'lib/portl/engine.rb', line 6 def output_buffer @output_buffer end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
4 5 6 |
# File 'lib/portl/engine.rb', line 4 def scope @scope end |
Instance Method Details
#html_tag(tag, *args, &block) ⇒ Object
Creates an HTML tag.
28 29 30 31 32 33 34 |
# File 'lib/portl/engine.rb', line 28 def html_tag(tag, *args, &block) if PORTL::HTML::NON_CLOSING_TAGS.include?(tag) output_buffer << raw("<#{tag}#{(args[0], true)}>") else output_buffer << content_tag(tag, *args, &block) end end |
#result ⇒ String
Compiles the data within the supplied scope and returns the result.
18 19 20 |
# File 'lib/portl/engine.rb', line 18 def result eval(data) end |
#text(value) ⇒ ActionView::OutputBuffer
Adds plain text to the output buffer.
40 41 42 |
# File 'lib/portl/engine.rb', line 40 def text(value) output_buffer << raw(value) end |