| Module | ActionView::Helpers::TagHelper |
| In: |
lib/mtag_helper.rb
|
Use these methods to generate Flex <mx:> tags programmatically when you can’t use a Builder. By default, they output XML compliant tags.
Returns a CDATA section with the given content. CDATA sections are used to escape blocks of text containing characters which would otherwise be recognized as markup. CDATA sections begin with the string <![CDATA[ and end with (and may not contain) the string ]]>.
cdata_section("private function clearForm():void {field_title.text = '';}")
# => <![CDATA[
private function clearForm():void {
field_title.text = '';
}
]]>
# File lib/mtag_helper.rb, line 75
75: def cdata_section(content)
76: "<![CDATA[#{content}]]>"
77: end
Returns the escaped xml without affecting existing escaped entities.
escape_once("1 > 2 & 3")
# => "1 < 2 & 3"
# File lib/mtag_helper.rb, line 83
83: def escape_once(html)
84: fix_double_escape(html_escape(html.to_s))
85: end
Returns an XML block tag of type name surrounding the content. Add attributes by passing an attributes hash to options. For attributes with no value, give it a value of true in the options hash. You can use symbols or strings for the attribute names.
content_tag('FormItem', content_tag('TextInput'), :id => "image_desc")
# => <mx:FormItem id="image_desc">
<mx:TextInput />
</mx:FormItem>
Instead of passing the content as an argument, you can also use a block in which case, you pass your options as the second parameter.
<% mx_content_tag 'FormItem', :id => "image_desc" do -%>
<mx:TextInput />
<% end -%>
# => <mx:FormItem id="image_desc"><mx:TextInput /></mx:FormItem>
Alternatively to passed in the tag name as a string, you can pass it in as a symbol and it will be CamelCased
content_tag(:form_item, content_tag(:text_input), :id => "image_desc")
# => <mx:FormItem id="image_desc">
<mx:TextInput />
</mx:FormItem>
# File lib/mtag_helper.rb, line 52
52: def mx_content_tag(name, content_or_options_with_block = nil, options = nil, &block)
53: name = name.to_s.camelize
54: if block_given?
55: options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
56: content = capture(&block)
57: concat(mx_content_tag_string(name, content, options), block.binding)
58: else
59: content = content_or_options_with_block
60: mx_content_tag_string(name, content, options)
61: end
62: end
Returns an empty XML tag of type name which by default is XML compliant. Add attributes by passing an attributes hash to options. For attributes with no value like (disabled and readonly), give it a value of true in the options hash. You can use symbols or strings for the attribute names.
tag("TextInput")
# => <mx:TextInput />
tag("TextInput", { :id => 'field_desc', :width => '274', text => '{ image_grid.selectedItem.desc }' })
# => <mx:TextInput width="274" text="{ image_grid.selectedItem.desc }" id="field_desc" />
# File lib/mtag_helper.rb, line 21
21: def mx_tag(name, options = nil, open = false)
22: name = name.to_s.camelize
23: "<#{tag_ns}#{name}#{tag_options(options) if options} />"
24: end