Class: Uniword::Template::Helpers::VariableHelper
- Inherits:
-
Object
- Object
- Uniword::Template::Helpers::VariableHelper
- Defined in:
- lib/uniword/template/helpers/variable_helper.rb
Overview
Helper for variable substitution in template elements.
Replaces element content with resolved variable values. Handles different element types (Paragraph, Run, TableCell).
Responsibility: Variable substitution only Single Responsibility Principle: Does NOT resolve or validate
Instance Method Summary collapse
-
#replace(element, value) ⇒ void
Replace element content with value.
Instance Method Details
#replace(element, value) ⇒ void
This method returns an undefined value.
Replace element content with value
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/uniword/template/helpers/variable_helper.rb', line 23 def replace(element, value) # Convert value to string text = value.to_s case element when Uniword::Wordprocessingml::Paragraph replace_paragraph(element, text) when Uniword::Wordprocessingml::Run replace_run(element, text) when Uniword::Wordprocessingml::TableCell replace_cell(element, text) else # Try to treat as paragraph-like replace_paragraph(element, text) if element.respond_to?(:runs) end end |