Class: Slight::DSL

Inherits:
Object
  • Object
show all
Includes:
DSLEssential, Utils
Defined in:
lib/slight/dsl.rb

Instance Method Summary collapse

Methods included from Utils

html_escape, url_encode

Methods included from DSLEssential

#br, #doctype, #hr, #inc, #js, #layout, #layout_yield, #title, #use

Constructor Details

#initialize(io) ⇒ DSL

Returns a new instance of DSL.



90
91
92
93
# File 'lib/slight/dsl.rb', line 90

def initialize(io)
  @output_buffer = io
  #@root = page_node.new("root")
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(fun, *param, &block) ⇒ Object



99
100
101
102
# File 'lib/slight/dsl.rb', line 99

def method_missing(fun, *param, &block)
  __dsl__define(fun)
  self.send(fun, *param, &block)
end

Instance Method Details

#binding_scopeObject



104
105
106
# File 'lib/slight/dsl.rb', line 104

def binding_scope
  binding
end

#echo(str) ⇒ Object



97
# File 'lib/slight/dsl.rb', line 97

def echo(str); @output_buffer << str; nil; end

#puts(str) ⇒ Object



95
# File 'lib/slight/dsl.rb', line 95

def puts(str); @output_buffer << html_escape(str); nil; end

#resolve_blinding(blinding) ⇒ Object



116
117
118
119
120
# File 'lib/slight/dsl.rb', line 116

def resolve_blinding(blinding)
  blinding.each do |m|
      undef_method m
  end
end

#resolve_local(var, val) ⇒ Object



122
123
124
125
126
127
128
# File 'lib/slight/dsl.rb', line 122

def resolve_local(var,val)
  self.singleton_class.class_eval do
    define_method(var.to_sym){
      return val
    }
  end
end

#resolve_shortcutA(shortcutA) ⇒ Object



108
109
110
# File 'lib/slight/dsl.rb', line 108

def resolve_shortcutA(shortcutA)
  @__dsl__attr_replacements = shortcutA
end

#resolve_shortcutT(shortcutT) ⇒ Object



112
113
114
# File 'lib/slight/dsl.rb', line 112

def resolve_shortcutT(shortcutT)
  @__dsl__tag_replacements = shortcutT
end