Class: Pieces::RouteCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/pieces/compilers/route_compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ RouteCompiler

Returns a new instance of RouteCompiler.



6
7
8
9
# File 'lib/pieces/compilers/route_compiler.rb', line 6

def initialize(config)
  @path = config[:path] || Dir.pwd
  @globals = config[:globals] || {}
end

Instance Attribute Details

#globalsObject (readonly)

Returns the value of attribute globals.



4
5
6
# File 'lib/pieces/compilers/route_compiler.rb', line 4

def globals
  @globals
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/pieces/compilers/route_compiler.rb', line 3

def path
  @path
end

Instance Method Details

#compile(files, name, route) ⇒ Object



11
12
13
# File 'lib/pieces/compilers/route_compiler.rb', line 11

def compile(files, name, route)
  files.merge("#{name}.html" => { contents: yield_pieces(route), type: 'html' })
end