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, 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
2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 |
# File 'lib/amrita2/template.rb', line 2352 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
2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 |
# File 'lib/amrita2/template.rb', line 2367 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
2347 2348 2349 2350 |
# File 'lib/amrita2/template.rb', line 2347 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
2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 |
# File 'lib/amrita2/template.rb', line 2381 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 |