Class: Bijou::Parse::Component
Overview
The class for the backend code generator that is used to render an entire component. It may contain a top-level %args block. This %args block is replicated for the %init block.
Instance Attribute Summary collapse
-
#cache_filename ⇒ Object
Returns the value of attribute cache_filename.
-
#directives ⇒ Object
Returns the value of attribute directives.
-
#source_filename ⇒ Object
Returns the value of attribute source_filename.
Attributes inherited from Target
Instance Method Summary collapse
- #add_method(d) ⇒ Object
- #component=(componentName) ⇒ Object
- #component_base=(componentBase) ⇒ Object
-
#initialize(use_markers) ⇒ Component
constructor
A new instance of Component.
- #require_list=(list) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Target
#render_args, #render_code, #render_code_, #render_expr, #render_line, #render_marker, #render_part
Constructor Details
#initialize(use_markers) ⇒ Component
Returns a new instance of Component.
181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/bijou/backend.rb', line 181 def initialize(use_markers) @name = '' @componentBase = 'Bijou::Component' @componentName = '' @output = '' @defs = [] @directives = {} @source_filename = nil @cache_filename = nil @use_markers = use_markers end |
Instance Attribute Details
#cache_filename ⇒ Object
Returns the value of attribute cache_filename.
193 194 195 |
# File 'lib/bijou/backend.rb', line 193 def cache_filename @cache_filename end |
#directives ⇒ Object
Returns the value of attribute directives.
193 194 195 |
# File 'lib/bijou/backend.rb', line 193 def directives @directives end |
#source_filename ⇒ Object
Returns the value of attribute source_filename.
193 194 195 |
# File 'lib/bijou/backend.rb', line 193 def source_filename @source_filename end |
Instance Method Details
#add_method(d) ⇒ Object
195 196 197 |
# File 'lib/bijou/backend.rb', line 195 def add_method(d) @defs.push(d) end |
#component=(componentName) ⇒ Object
199 200 201 |
# File 'lib/bijou/backend.rb', line 199 def component=(componentName) @componentName = componentName end |
#component_base=(componentBase) ⇒ Object
203 204 205 |
# File 'lib/bijou/backend.rb', line 203 def component_base=(componentBase) @componentBase = componentBase end |
#require_list=(list) ⇒ Object
207 208 209 |
# File 'lib/bijou/backend.rb', line 207 def require_list=(list) @requireList = list end |
#to_s ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/bijou/backend.rb', line 211 def to_s result = '' if @directives.has_key?('base') @componentBase = @directives['base'] end if @args @defs.each {|d| if d.name == 'init' # NOTE: The init block has the same argument expansion as render. d.args = @args.clone break end } end result << "require 'bijou/component'\n" if @requireList @requireList.each {|path| result << "require '#{path}'\n" } end result << "class #{@componentName} < #{@componentBase}\n" if @directives.has_key?('container') result << " def self.container\n" result << " '#{@directives['container']}'\n" result << " end\n" end # REVIEW: Do we need to escape? The filenames appear to always use # forward slashes. if @source_filename result << " def self.source_filename\n" result << " '#{@source_filename}'\n" result << " end\n" end if @cache_filename result << " def self.cache_filename\n" result << " '#{@cache_filename}'\n" result << " end\n" end result << " def render(args)\n" result << render_args('render', @use_markers) result << @output; result << " end\n" @defs.each {|d| result << d.render_method(@use_markers) } result << "end\n" return result end |