Methods |
Classes and Modules |
Public Class methods |
def_tag(tagname, *attrs_p) |
# File lib/amrita/node.rb, line 749 def klass::def_tag(tagname, *attrs_p) def_tag2(tagname, tagname, *attrs_p) end
def_tag2(methodname, tagname, *attrs_p) |
# File lib/amrita/node.rb, line 753 def klass::def_tag2(methodname, tagname, *attrs_p) methodname = methodname.id2name tagname = tagname.id2name attrs = attrs_p.collect { |a| a.id2name } if attrs.size > 0 param = attrs.collect { |a| "#{a}=nil" }.join(", ") param += ",*args,&block" method_body = " e(:#{tagname}, " method_body += attrs.collect { |a| "A(:#{a}, #{a})"}.join(", ") method_body += ", *args, &block)" else param = "*args, &block" method_body = " e(:#{tagname}, *args, &block) " end a = "def #{methodname}(#{param}) \n#{method_body}\nend\n" #print a eval a end
Public Instance methods |
convert(s) |
# File lib/amrita/xml.rb, line 15 def convert(s) Uconv::u8toeuc(s) end
convert(s) |
# File lib/amrita/xml.rb, line 19 def convert(s) Uconv::u8tosjis(s) end
convert(s) |
# File lib/amrita/xml.rb, line 23 def convert(s) s end
convert(s) |
# File lib/amrita/xml.rb, line 28 def convert(s) s end
e(tagname, *attrs, &block) |
# File lib/amrita/node.rb, line 698 def e(tagname, *attrs, &block) Element.new(tagname, *attrs, &block) end
element(tagname, *attrs, &block) |
Alias for e
a(*x, &block) |
generate AttrArray object
# File lib/amrita/node.rb, line 706 def a(*x, &block) case x.size when 1 x = x[0] case x when Hash when String,Symbol x = Attr.new(x) when Attr else raise(TypeError, "Not Attr,String or Symbol: #{x}") end AttrArray.new(x, &block) when 0 AttrArray.new([], &block) else a = (0...x.size/2).collect do |i| Attr.new(x[i*2], x[i*2+1]) end AttrArray.new(a, &block) end end
attr(*x, &block) |
Alias for a
format_inline(data=true, &block) {|| ...} |
format a Node object given as block in single line format.
If data was given, expand will be called before formatting
# File lib/amrita/format.rb, line 686 def format_inline(data=true, &block) node = Node::to_node(yield) f = SingleLineFormatter.new f.format(node.expand1(data)) end
format_pretty(data=true, &block) {|| ...} |
pretty print a Node object given as block
If data was given, expand will be called before formatting
# File lib/amrita/format.rb, line 698 def format_pretty(data=true, &block) node = Node::to_node(yield) f = PrettyPrintFormatter.new f.format(node.expand1(data)) end
noescape(&block) |
Usually the <> character in text will be escaped.
tmpl = TemplateText.new "<p id=x></p>" tmpl.expand(STDOUT, {:x => "<tag>"}) # => <p><tag></p>
If the text was wrapped by this method, it will no be escaped.
tmpl.expand(STDOUT, {:x => noescape {"<tag>"}}) # => <p><tag></p>
# File lib/amrita/format.rb, line 715 def noescape(&block) Escape.new(false, &block) end
pre(*attrs, &block) |
If the text was wrapped by this method, spaces in it will be keeped.
# File lib/amrita/format.rb, line 722 def pre(*attrs, &block) Element.new(:pre, *attrs) { CompactSpace.new(false, &block) } end