Module: AdLocalize::Serializers::WithTemplate
- Included in:
- InfoPlistSerializer, LocalizableStringsSerializer, LocalizableStringsdictSerializer, PropertiesSerializer, StringsSerializer
- Defined in:
- lib/ad_localize/serializers/with_template.rb
Constant Summary collapse
- TEMPLATES_DIRECTORY =
__dir__ + "/../templates"
Instance Method Summary collapse
Instance Method Details
#render(locale_wording:) ⇒ Object
6 7 8 9 10 |
# File 'lib/ad_localize/serializers/with_template.rb', line 6 def render(locale_wording:) hash_binding = hash_binding(locale_wording: locale_wording) return unless hash_binding render_template(template_path: template_path, hash_binding: hash_binding) end |
#render_template(template_path:, hash_binding:) ⇒ Object
12 13 14 15 16 |
# File 'lib/ad_localize/serializers/with_template.rb', line 12 def render_template(template_path:, hash_binding:) template = File.read(template_path) renderer = ERB.new(template, trim_mode: '-') renderer.result_with_hash(hash_binding) end |