Class: Malline::Base
- Inherits:
-
Object
- Object
- Malline::Base
- Defined in:
- lib/malline.rb
Overview
Malline handler, always use Malline engine with this handler = Malline.new @view, :strict => false handler.
Constant Summary collapse
- @@options =
Default options, can be changed with setopt
{ :strict => true, :xhtml => true, :encoding => 'UTF-8', :lang => 'en', :form_for_proxy => true }
Instance Attribute Summary collapse
-
#malline ⇒ Object
Returns the value of attribute malline.
Class Method Summary collapse
- .render(tpl = nil, local_assigns = {}, &block) ⇒ Object
-
.setopt(hash) ⇒ Object
for example: setopt :strict => false.
Instance Method Summary collapse
- #definetags(*args) ⇒ Object
- #definetags!(*args) ⇒ Object
-
#initialize(*opts) ⇒ Base
constructor
First parameter is the view object (if any) Last parameter is optional options hash.
-
#path ⇒ Object
Get the current filename.
- #path=(npath) ⇒ Object
- #render(tpl = nil, local_assigns = {}, &block) ⇒ Object
Constructor Details
#initialize(*opts) ⇒ Base
First parameter is the view object (if any) Last parameter is optional options hash
46 47 48 49 50 51 52 53 |
# File 'lib/malline.rb', line 46 def initialize *opts @options = @@options.dup @options.merge! opts.pop if opts.last.is_a?(Hash) @view = opts.shift || Class.new @view.extend ViewWrapper unless @view.is_a?(ViewWrapper) @malline = @view.malline @options end |
Instance Attribute Details
#malline ⇒ Object
Returns the value of attribute malline.
33 34 35 |
# File 'lib/malline.rb', line 33 def malline @malline end |
Class Method Details
.render(tpl = nil, local_assigns = {}, &block) ⇒ Object
87 88 89 |
# File 'lib/malline.rb', line 87 def self.render tpl = nil, local_assigns = {}, &block self.new.render tpl, local_assigns, &block end |
.setopt(hash) ⇒ Object
for example: setopt :strict => false
or: setopt :strict => false something setopt :strict => true do
something strict
end
73 74 75 76 77 78 79 80 |
# File 'lib/malline.rb', line 73 def self.setopt hash return @@options.merge!(hash) unless block_given? old = @@options.dup @@options.merge! hash if hash yield ensure @@options = old if old end |
Instance Method Details
#definetags(*args) ⇒ Object
91 92 93 |
# File 'lib/malline.rb', line 91 def *args @view.malline. *args end |
#definetags!(*args) ⇒ Object
95 96 97 |
# File 'lib/malline.rb', line 95 def *args @view.malline. *args end |
#path ⇒ Object
Get the current filename
56 57 58 |
# File 'lib/malline.rb', line 56 def path @view.malline.path end |
#path=(npath) ⇒ Object
60 61 62 |
# File 'lib/malline.rb', line 60 def path= npath @view.malline.path = npath end |
#render(tpl = nil, local_assigns = {}, &block) ⇒ Object
82 83 84 85 |
# File 'lib/malline.rb', line 82 def render tpl = nil, local_assigns = {}, &block add_local_assigns local_assigns @view.malline.run tpl, &block end |