Class: Rad::TemplateContext
Instance Attribute Summary collapse
Instance Method Summary
collapse
#capture, #concat, #output
Instance Attribute Details
#_tilt_template ⇒ Object
8
9
10
|
# File 'lib/rad/template/template_context.rb', line 8
def _tilt_template
@_tilt_template
end
|
#content_block ⇒ Object
36
37
38
|
# File 'lib/rad/template/template_context.rb', line 36
def content_block
@content_block
end
|
8
9
10
|
# File 'lib/rad/template/template_context.rb', line 8
def options
@options
end
|
#scope_variables ⇒ Object
for saving :format, :current_dir and others def scope_variables; @scope_variables ||= OpenObject.new end
12
13
14
|
# File 'lib/rad/template/template_context.rb', line 12
def scope_variables
@scope_variables
end
|
Instance Method Details
#content_for(name, content = nil, &block) ⇒ Object
38
39
40
41
42
|
# File 'lib/rad/template/template_context.rb', line 38
def content_for name, content = nil, &block
content ||= capture(&block)
(content_variables[name.to_s] ||= "") << content
nil
end
|
#content_variables ⇒ Object
37
|
# File 'lib/rad/template/template_context.rb', line 37
def content_variables; @content_variables ||= {}.to_openobject end
|
#has_content_for?(name) ⇒ Boolean
54
55
56
|
# File 'lib/rad/template/template_context.rb', line 54
def has_content_for? name
content_variables.include? name.to_s
end
|
28
29
30
|
# File 'lib/rad/template/template_context.rb', line 28
def j obj
obj.to_s.json_escape
end
|
58
59
60
|
# File 'lib/rad/template/template_context.rb', line 58
def params
workspace.params
end
|
#prepend_to(name, content = nil, &block) ⇒ Object
43
44
45
46
47
|
# File 'lib/rad/template/template_context.rb', line 43
def prepend_to name, content = nil, &block
content ||= capture(&block)
(content_variables[name.to_s] ||= "").insert 0, content
nil
end
|
#wrap_content_for(name, &block) ⇒ Object
48
49
50
51
52
53
|
# File 'lib/rad/template/template_context.rb', line 48
def wrap_content_for name, &block
block.must_be.defined
content = capture((content_variables[name.to_s] || ""), &block)
content_variables[name.to_s] ||= content
nil
end
|