Class: Synvert::Core::Rewriter::ReplaceErbStmtWithExprAction
- Defined in:
- lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb
Overview
ReplaceErbStmtWithExprAction to replace erb stmt code to expr,
Constant Summary
Constants inherited from Action
Instance Attribute Summary
Attributes inherited from Action
Instance Method Summary collapse
-
#initialize(instance) ⇒ ReplaceErbStmtWithExprAction
constructor
Initialize a ReplaceErbStmtWithExprAction.
-
#rewritten_code ⇒ String
The rewritten erb expr code.
Methods inherited from Action
Constructor Details
#initialize(instance) ⇒ ReplaceErbStmtWithExprAction
Initialize a ReplaceErbStmtWithExprAction.
11 12 13 |
# File 'lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb', line 11 def initialize(instance) super(instance, nil) end |
Instance Method Details
#rewritten_code ⇒ String
The rewritten erb expr code.
18 19 20 21 22 |
# File 'lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb', line 18 def rewritten_code @node.loc.expression.source_buffer.source[begin_pos...end_pos] .sub(Engine::ERUBY_STMT_SPLITTER, '@output_buffer.append= ') .sub(Engine::ERUBY_STMT_SPLITTER, Engine::ERUBY_EXPR_SPLITTER) end |