Module: I18n::Backend::InterpolationCompiler::Compiler
Constant Summary collapse
- TOKENIZER =
/(%%\{[^\}]+\}|%\{[^\}]+\})/- INTERPOLATION_SYNTAX_PATTERN =
/(%)?(%\{([^\}]+)\})/
Instance Method Summary collapse
Instance Method Details
#compile_if_an_interpolation(string) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/i18n/backend/interpolation_compiler.rb', line 25 def compile_if_an_interpolation(string) if interpolated_str?(string) string.instance_eval " def i18n_interpolate(v = {})\n \"\#{compiled_interpolation_body(string)}\"\n end\n RUBY_EVAL\n end\n\n string\nend\n", __FILE__, __LINE__ |
#interpolated_str?(str) ⇒ Boolean
37 38 39 |
# File 'lib/i18n/backend/interpolation_compiler.rb', line 37 def interpolated_str?(str) str.kind_of?(::String) && str =~ INTERPOLATION_SYNTAX_PATTERN end |