Class: Amrita2::Filters::InlineRuby
- Defined in:
- lib/amrita2/template.rb
Overview
:nodoc: all
Constant Summary
Constants included from Util
Util::AMP_WITHOUT_REFRENCE, Util::DefaultAllowedScheme, Util::NAME, Util::NAMECHAR, Util::NOT_REFERENCE, Util::UrlInvalidChar
Constants included from Amrita2
Amrita2::FilterMethods, Hooki, SanitizedString
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #generate_dynamic_element(de, e) ⇒ Object
- #loop_check_code(de, cg) ⇒ Object
- #setup_type_renderer(de) ⇒ Object
- #value_filter_code(de, cg, value) ⇒ Object
Methods included from Util
sanitize_attribute_value, sanitize_text, sanitize_url
Methods included from Runtime
#amrita_get_context_value, #amrita_set_context_value, #end_tag, #new_element, #start_tag
Methods inherited from Base
filter_method, inherited, #parse_filter_a, #|
Instance Method Details
#generate_dynamic_element(de, e) ⇒ Object
2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 |
# File 'lib/amrita2/template.rb', line 2247 def generate_dynamic_element(de, e) a = e.attributes ret = super return ret if ret # check if element has any of inlineruby attributes if %w(am_skipif am_for am_v).any? { |k| a[de.__send__(k)] } filters_src = e.attributes[de.am_filter] filters = de.root.compile_filters(e, nil, filters_src) Core::DynamicElement.new(de, nil , e, filters) else nil end end |
#loop_check_code(de, cg) ⇒ Object
2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 |
# File 'lib/amrita2/template.rb', line 2262 def loop_check_code(de, cg) foreach_ = de.am_for_value if foreach_ cg.if_("__cnt__ < 0") do #cg.code("$_ = eval(#{foreach_.inspect}, __binding__)") cg.code("$_ = ") cg.eval(foreach_.inspect) super end else super end end |
#setup_type_renderer(de) ⇒ Object
2242 2243 2244 2245 |
# File 'lib/amrita2/template.rb', line 2242 def setup_type_renderer(de) de.renderers << HashRenderer.new unless de.renderers.find {|r| r.kind_of?(HashRenderer) } super end |
#value_filter_code(de, cg, value) ⇒ Object
2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 |
# File 'lib/amrita2/template.rb', line 2276 def value_filter_code(de, cg, value) cond = de.am_skipif_value value = de.am_v_value if cond cg.code("amrita_set_context_value($_)") #cg.code("return '' if eval(#{with_context_value_expression(cond).inspect},__binding__)") cg.code("return '' if \\") cg.eval(with_context_value_expression(cond).inspect) end if value cg.code("amrita_set_context_value($_)") #cg.code("$_ = eval(#{with_context_value_expression(value).inspect},__binding__)") cg.code("$_ = ") cg.eval(with_context_value_expression(value).inspect) end super end |