Class: Marker::Template
- Inherits:
-
ParseNode
- Object
- Treetop::Runtime::SyntaxNode
- ParseNode
- Marker::Template
- Defined in:
- lib/marker/templates.rb
Instance Method Summary collapse
- #arg_list(format, options) ⇒ Object
-
#args ⇒ Object
:nodoc:.
- #block? ⇒ Boolean
- #render(format, options = {}) ⇒ Object
-
#t ⇒ Object
– defaults ++.
- #target ⇒ Object
- #to_html(options = {}) ⇒ Object
- #to_s(options = {}) ⇒ Object
Methods inherited from Treetop::Runtime::SyntaxNode
Instance Method Details
#arg_list(format, options) ⇒ Object
43 44 45 |
# File 'lib/marker/templates.rb', line 43 def arg_list( format, ) ( args ? args.to_arg_list( format, ) : [[], {}] ) end |
#args ⇒ Object
:nodoc:
56 57 58 |
# File 'lib/marker/templates.rb', line 56 def args #:nodoc: nil end |
#block? ⇒ Boolean
47 48 49 |
# File 'lib/marker/templates.rb', line 47 def block? ( args ? args.block? : false ) end |
#render(format, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/marker/templates.rb', line 28 def render( format, = {} ) # optionally change the format for argument rendering if [:template_formats] and [:template_formats][target] format = [:template_formats][target] end ordered, named = arg_list( format, ) Marker.templates.send( target, format, ordered, named, ) end |
#t ⇒ Object
– defaults ++
52 53 54 |
# File 'lib/marker/templates.rb', line 52 def t #:nodoc: nil end |
#target ⇒ Object
38 39 40 41 |
# File 'lib/marker/templates.rb', line 38 def target # sanitize the string to get a method name t.text_value.downcase.gsub(/\s/, '_').to_sym end |
#to_html(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/marker/templates.rb', line 11 def to_html( = {} ) # if this template contains block-style arguments, then it needs to be # wrapped in a div. otherwise, all arguments are inline and it does not # get wrapped. the template target is used as the html class. # # it may be a good idea to wrap inline templates in a span if block? "<div class='#{target}'>#{render( :html, )}</div>" else render( :html, ) end end |
#to_s(options = {}) ⇒ Object
24 25 26 |
# File 'lib/marker/templates.rb', line 24 def to_s( = {} ) render( :text, ) end |