Class: VueCK::SFC

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component_file) ⇒ SFC

Returns a new instance of SFC.



5
6
7
8
9
# File 'lib/sfc.rb', line 5

def initialize(component_file)
    @path = component_file
    @xml  = component_xml
    @name = @xml.attribute(ATTRIBUTES[:name]).value
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/sfc.rb', line 3

def name
  @name
end

#scriptObject

Returns the value of attribute script.



3
4
5
# File 'lib/sfc.rb', line 3

def script
  @script
end

#styleObject

Returns the value of attribute style.



3
4
5
# File 'lib/sfc.rb', line 3

def style
  @style
end

#templateObject

Returns the value of attribute template.



3
4
5
# File 'lib/sfc.rb', line 3

def template
  @template
end

#xmlObject

Returns the value of attribute xml.



3
4
5
# File 'lib/sfc.rb', line 3

def xml
  @xml
end

Instance Method Details

#render_componentObject



11
12
13
# File 'lib/sfc.rb', line 11

def render_component
    reduce_whitespace "var #{@name} = Vue.component('#{@name}',{template:'#{render(:template)}', #{render(:script)}});"
end

#render_styleObject



15
16
17
18
19
# File 'lib/sfc.rb', line 15

def render_style
    style = Element.new(@xml, :style)
    return "" if style.empty?
    CSSminify.compress reduce_whitespace(style.render)
end