Module: SyntaxTree::ERB

Defined in:
lib/syntax_tree/erb.rb,
lib/syntax_tree/erb/nodes.rb,
lib/syntax_tree/erb/format.rb,
lib/syntax_tree/erb/parser.rb,
lib/syntax_tree/erb/version.rb,
lib/syntax_tree/erb/visitor.rb,
lib/syntax_tree/erb/pretty_print.rb

Defined Under Namespace

Classes: Block, CharData, Doctype, Document, Element, ErbBlock, ErbCase, ErbCaseWhen, ErbClose, ErbComment, ErbContent, ErbControl, ErbDoClose, ErbElse, ErbElsif, ErbEnd, ErbIf, ErbNode, ErbUnless, ErbYield, Format, HtmlAttribute, HtmlComment, HtmlNode, HtmlString, NewLine, Node, Parser, PrettyPrint, Token, Visitor

Constant Summary collapse

MAX_WIDTH =
80
VERSION =
"0.12.0"

Class Method Summary collapse

Class Method Details

.format(source, maxwidth = MAX_WIDTH, options: nil) ⇒ Object



16
17
18
# File 'lib/syntax_tree/erb.rb', line 16

def self.format(source, maxwidth = MAX_WIDTH, options: nil)
  PrettierPrint.format(+"", maxwidth) { |q| parse(source).format(q) }
end

.parse(source) ⇒ Object



20
21
22
# File 'lib/syntax_tree/erb.rb', line 20

def self.parse(source)
  Parser.new(source).parse
end

.read(filepath) ⇒ Object



24
25
26
# File 'lib/syntax_tree/erb.rb', line 24

def self.read(filepath)
  File.read(filepath)
end