class Phlex::Compiler::Generators::Content
def bare_string_value
def bare_string_value @formatter.append do |f| f.text Hescape.escape_html( @content.parts.first.value ) end end
def bare_string_value?
def bare_string_value? case @content in SyntaxTree::StringLiteral[parts: [SyntaxTree::TStringContent]] true else false end end
def call
def call return if nil_value? return bare_string_value if bare_string_value? return symbol_value if symbol_value? return numeric_value if numeric_value? return variable_value if variable_value? unknown_value end
def initialize(formatter, content:, mutating: false)
def initialize(formatter, content:, mutating: false) @formatter = formatter @content = content @mutating = mutating end
def nil_value?
def nil_value? case @content in SyntaxTree::VarRef[value: SyntaxTree::Kw[value: "nil"]] true else false end end
def numeric_value
def numeric_value @formatter.append do |f| f.text Hescape.escape_html( @content.value ) end end
def numeric_value?
def numeric_value? @content.is_a?(SyntaxTree::Int) || @content.is_a?(SyntaxTree::FloatLiteral) end
def symbol_value
def symbol_value @formatter.append do |f| f.text Hescape.escape_html( @content.value.value ) end end
def symbol_value?
def symbol_value? @content.is_a?(SyntaxTree::SymbolLiteral) end
def unknown_value
def unknown_value @formatter.breakable(force: true) if @mutating @content.format(@formatter) else @formatter.text "yield_content {" @formatter.breakable(force: true) @content.format(@formatter) @formatter.breakable(force: true) @formatter.text "}" end @formatter.breakable(force: true) end
def variable_value
def variable_value @formatter.chain_append do |f| f.text "Hescape.escape_html(" @content.format(f) f.text ")" end end
def variable_value?
def variable_value? @content.is_a?(SyntaxTree::VarRef) end