Class: Kwartz::JstlTranslator
- Inherits:
-
BaseTranslator
- Object
- Translator
- BaseTranslator
- Kwartz::JstlTranslator
- Includes:
- JstlExpressionParser
- Defined in:
- lib/kwartz/binding/jstl.rb
Overview
translator for php
Direct Known Subclasses
Constant Summary collapse
- JSTL11_EMBED_PATTERNS =
[ '', '', # statement '<c:out value="${', '}" escapeXml="false"/>', # expression '<c:out value="${', '}"/>' # escaped expression ]
- JSTL12_EMBED_PATTERNS =
[ '', '', # statement '<c:out value="${', '}" escapeXml="false"/>', # expression '${', '}' # escaped expression ]
Instance Attribute Summary
Attributes inherited from BaseTranslator
Instance Method Summary collapse
-
#initialize(properties = {}) ⇒ JstlTranslator
constructor
A new instance of JstlTranslator.
- #translate_native_expr(expr) ⇒ Object
Methods included from JstlExpressionParser
#parse_expr_str, #parse_expr_str!
Methods inherited from BaseTranslator
#translate, #translate_native_stmt, #translate_print_stmt, #translate_string
Methods inherited from Translator
get_class, register_class, #translate, #translate_native_stmt, #translate_print_stmt, #translate_string
Constructor Details
#initialize(properties = {}) ⇒ JstlTranslator
Returns a new instance of JstlTranslator.
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/kwartz/binding/jstl.rb', line 343 def initialize(properties={}) jstl_ver = properties[:jstl] || Config::PROPERTY_JSTL super(jstl_ver < 1.2 ? JSTL11_EMBED_PATTERNS : JSTL12_EMBED_PATTERNS, properties) @jstl_ver = jstl_ver unless self.header sb = '' if charset = properties[:charset] sb << "<%@ page contentType=\"text/html; charset=#{charset}\" %>" << @nl else #sb << "<%@ page contentType=\"text/html\" %>" << @nl end if @jstl_ver < 1.2 sb << '<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>' << @nl else sb << '<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>' << @nl sb << '<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>' << @nl end self.header = sb end end |
Instance Method Details
#translate_native_expr(expr) ⇒ Object
365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/kwartz/binding/jstl.rb', line 365 def translate_native_expr(expr) assert unless expr.is_a?(NativeExpression) if expr.code =~ /\A"(.*)"\z/ || expr.code =~ /\A'(.*)'\z/ @sb << $1 else flag_escape = expr.escape? flag_escape = @escape if flag_escape.nil? if flag_escape == false @sb << @expr_l << expr.code << @expr_r # ex. <c:out value="${expr}" escapeXml="false"/> else @sb << @escape_l << expr.code << @escape_r # ex. <c:out value="${expr}"/> end end end |