Class: Plate::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/plate/compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCompiler

Returns a new instance of Compiler.



7
8
9
10
11
# File 'lib/plate/compiler.rb', line 7

def initialize
  @parser = Parser.new
  self.repeating = false
  self.meta = {}
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



6
7
8
# File 'lib/plate/compiler.rb', line 6

def body
  @body
end

#metaObject

Returns the value of attribute meta.



6
7
8
# File 'lib/plate/compiler.rb', line 6

def meta
  @meta
end

#repeatingObject

Returns the value of attribute repeating.



6
7
8
# File 'lib/plate/compiler.rb', line 6

def repeating
  @repeating
end

Instance Method Details

#compile(code) ⇒ Object



13
14
15
16
17
# File 'lib/plate/compiler.rb', line 13

def compile(code)
  self.body = @parser
    .parse(code)
    .compile(self)
end

#fontsObject



19
20
21
22
23
24
# File 'lib/plate/compiler.rb', line 19

def fonts
  return '' if meta['fonts'].nil?
  meta['fonts'].map { |font|
    "<link href=\"http://fonts.googleapis.com/css?family=#{CGI.escape(font)}\" rel=\"stylesheet\">"
  }.join("")
end

#repeating?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/plate/compiler.rb', line 26

def repeating?
  repeating
end