module BraceMarkup
Constants
- DEFAULT_FILE_EXTENSION
- VERSION
Public Class Methods
parse(input)
click to toggle source
Parses a raw input
# File lib/brace_markup.rb, line 41 def self.parse(input) Parser.new.parse(input) end
parse_file(file)
click to toggle source
Parses a file and returns the AST objects.
# File lib/brace_markup.rb, line 34 def self.parse_file(file) self.parse(get_file_contents(file)) end
render(input, context: nil, vars: {}, filename: nil)
click to toggle source
Renders a given raw string with a given context.
# File lib/brace_markup.rb, line 14 def self.render(input, context: nil, vars: {}, filename: nil) # Parse the given string ast = self.parse(input) context = Context.new(vars, filename: filename) unless context.is_a? Context # Calls the renderer Renderer.render(ast, context) end
render_file(file, context = {})
click to toggle source
Renders a file
# File lib/brace_markup.rb, line 27 def self.render_file(file, context = {}) self.render(get_file_contents(file), context, filename: file) end
Private Class Methods
get_file_contents(file)
click to toggle source
# File lib/brace_markup.rb, line 47 def self.get_file_contents(file) # Auto - append the filename if there is none if File.extname(file).empty? file += DEFAULT_FILE_EXTENSION end if File.file?(file) && File.readable?(file) File.open(file, "rb").read else raise Exception.new "Could not open file '#{file}'" end end