Class: Crystal::TemplateContext
Instance Attribute Summary collapse
Instance Method Summary
collapse
#capture, #concat, #output
Instance Attribute Details
#_tilt_template ⇒ Object
8
9
10
|
# File 'lib/crystal/template/template_context.rb', line 8
def _tilt_template
@_tilt_template
end
|
#content_block ⇒ Object
31
32
33
|
# File 'lib/crystal/template/template_context.rb', line 31
def content_block
@content_block
end
|
8
9
10
|
# File 'lib/crystal/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/crystal/template/template_context.rb', line 12
def scope_variables
@scope_variables
end
|
Instance Method Details
#content_for(name, content = nil, &block) ⇒ Object
33
34
35
36
37
|
# File 'lib/crystal/template/template_context.rb', line 33
def content_for name, content = nil, &block
content ||= capture(&block)
(content_variables[name.to_s] ||= "") << content
nil
end
|
#content_variables ⇒ Object
32
|
# File 'lib/crystal/template/template_context.rb', line 32
def content_variables; @content_variables ||= {} end
|
#has_content_for?(name) ⇒ Boolean
49
50
51
|
# File 'lib/crystal/template/template_context.rb', line 49
def has_content_for? name
content_variables.include? name.to_s
end
|
53
54
55
|
# File 'lib/crystal/template/template_context.rb', line 53
def params
workspace.params
end
|
#prepend_to(name, content = nil, &block) ⇒ Object
38
39
40
41
42
|
# File 'lib/crystal/template/template_context.rb', line 38
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
43
44
45
46
47
48
|
# File 'lib/crystal/template/template_context.rb', line 43
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
|