Class: Kwartz::JstlTranslator
- Inherits:
-
BaseTranslator
- Object
- Translator
- BaseTranslator
- Kwartz::JstlTranslator
- 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 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.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/kwartz/binding/jstl.rb', line 306 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
328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'lib/kwartz/binding/jstl.rb', line 328 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 |