Class: HtmlMockup::MockupTemplate

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/html_mockup/mockup_template.rb

Defined Under Namespace

Classes: MissingPartial, TemplateContext

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#scannerObject (readonly)

Returns the value of attribute scanner.



16
17
18
# File 'lib/html_mockup/mockup_template.rb', line 16

def scanner
  @scanner
end

Class Method Details

.engine_initialized?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/html_mockup/mockup_template.rb', line 18

def self.engine_initialized?
  true
end

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/html_mockup/mockup_template.rb', line 26

def evaluate(scope, locals, &block)
  @scanner = StringScanner.new(data)      
  out = ""
  while (partial = self.parse_partial_tag!) do
    name, params, scanned = partial
    # add new skipped content to output file
    out << scanned

    # scan until end of tag
    current_content = self.scanner.scan_until(/<!-- \[STOP:#{name}\] -->/)
    out << (render_partial(name, params, scope) || current_content)
  end
  out << scanner.rest  

  @output = out
end

#prepareObject



22
23
24
# File 'lib/html_mockup/mockup_template.rb', line 22

def prepare
  
end