class Bade::Runtime::RenderBinding
Attributes
__base_indent[RW]
Holds @return [String]
__buffs_stack[RW]
@return [Array<Array<String>>]
__mixins[RW]
@return [Hash<String, Mixin>]
__new_line[RW]
Holds @return [String]
Public Class Methods
new(vars = {})
click to toggle source
@param vars [Hash]
# File lib/bade/runtime/render_binding.rb, line 25 def initialize(vars = {}) __reset vars.each do |key, value| raise KeyError, "Already defined variable #{key.inspect} in this binding" if respond_to?(key.to_sym) define_singleton_method(key) do value end end end
Public Instance Methods
__buff()
click to toggle source
— Methods for dealing with pushing and poping buffers in stack
# File lib/bade/runtime/render_binding.rb, line 64 def __buff __buffs_stack.last end
__buffs_pop()
click to toggle source
# File lib/bade/runtime/render_binding.rb, line 72 def __buffs_pop __buffs_stack.pop end
__buffs_push()
click to toggle source
# File lib/bade/runtime/render_binding.rb, line 68 def __buffs_push __buffs_stack.push([]) end
__create_block(name, &block)
click to toggle source
Shortcut for creating blocks
# File lib/bade/runtime/render_binding.rb, line 54 def __create_block(name, &block) Bade::Runtime::Block.new(name, self, &block) end
__create_mixin(name, &block)
click to toggle source
# File lib/bade/runtime/render_binding.rb, line 58 def __create_mixin(name, &block) Bade::Runtime::Mixin.new(name, self, &block) end
__get_binding()
click to toggle source
@return [Binding]
# File lib/bade/runtime/render_binding.rb, line 48 def __get_binding binding end
__html_escaped(text)
click to toggle source
Escape input text with html escapes
@param [String] text
@return [String]
# File lib/bade/runtime/render_binding.rb, line 82 def __html_escaped(text) return nil if text.nil? text.gsub('&', '&') .gsub('<', '<') .gsub('>', '>') .gsub('"', '"') end
__reset()
click to toggle source
Resets this binding to default state, this method should be envoked after running the template lambda
@return [nil]
# File lib/bade/runtime/render_binding.rb, line 41 def __reset @__buffs_stack = [[]] @__mixins = Hash.new { |_hash, key| raise "Undefined mixin '#{key}'" } end
__tag_render_attribute(name, *values)
click to toggle source
# File lib/bade/runtime/render_binding.rb, line 91 def __tag_render_attribute(name, *values) values = values.compact return if values.empty? %( #{name}="#{values.join(' ')}") end