Class: Amrita::Template

Class Amrita::Template |
In: | lib/amrita/template.rb lib/amrita/parts.rb
Parent: | Object

Methods

expand new set_hint set_hint_by_sample_data

Attributes

:amrita_id | [RW] | The name of attribute that will be used for template expandion by amrita. You will need to set this if you use id attribute fom DOM. For expample, if this was set to "amrita_id", you can use amrita_id for amrita and id for DOM.
:asxml | [RW] | If set, the output is an xhtml document.
:cache_manager | [RW] |
:compact_space | [RW] | compact spaces and delete new line of output if set. you can't set prettyprint and compact_space both in same Template.
:debug_compiler | [RW] | debug compiler
:escaped_id | [RW] | The name of attribute that turns into id. You will need to set this if you use id attribute for DOM/CSS/etc... For expample, if this was set to "__id", you can use id for amrita and __id for DOM/CSS/etc....
:expand_attr | [RW] | If set, expand attribute which value is "@xxxx"
:keep_id | [RW] | keep id attribute of output if set.
:pre_format | [RW] | If Set, use pre_format method
:prettyprint | [RW] | output is pretty printed if set.
:src | [R] | The source code that generated by template compiler
:template | [R] |
:use_compiler | [RW] | If Set, use compiler.
:xml | [RW] | If set, use REXML-based parser instead of Amrita's own html-parser

Included modules

Amrita Amrita PartsTemplate HtmlCompiler::RuntimeRoutines

Public Class methods

new()

    # File lib/amrita/template.rb, line 93
        def initialize
          @hint = nil
          @template = nil
          @xml = @prettyprint = @compact_space = @asxml = @pre_format = @expand_attr= false
          @keep_id = false
          @escaped_id = @dom_id = @amrita_id = nil
          @parser_filter = nil
          @use_compiler = false
          @cache_manager = DummyCacheManager.new
          @debug_compiler = false
        end

Public Instance methods

expand(stream, model)

1. load template if it was changed
2. compile template if `use_compiler` was set.
3. expand template with `model`
4. print template to `stream`

    # File lib/amrita/template.rb, line 114
        def expand(stream, model)
          setup_template if need_update?
          context = setup_context
          formatter = setup_formatter(stream)
          do_expand(model, context, formatter)
        end

set_hint(hint)

set Hint data (undocumented now) and compile template by it.

    # File lib/amrita/template.rb, line 122
        def set_hint(hint)
          @hint = hint
          compile_template if @use_compiler
        end

set_hint_by_sample_data(data)

generate Hint from data and compile template by it.

    # File lib/amrita/template.rb, line 128
        def set_hint_by_sample_data(data)
          hint = data.amrita_generate_hint
          set_hint(hint)
        end