class VueCK::SFC
Attributes
name[RW]
script[RW]
style[RW]
template[RW]
xml[RW]
Public Class Methods
new(component_file)
click to toggle source
# File lib/sfc.rb, line 5 def initialize(component_file) @path = component_file @xml = component_xml @name = @xml.attribute(ATTRIBUTES[:name]).value end
Public Instance Methods
render_component()
click to toggle source
# File lib/sfc.rb, line 11 def render_component reduce_whitespace "var #{@name} = Vue.component('#{@name}',{template:'#{render(:template)}', #{render(:script)}});" end
render_style()
click to toggle source
# 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
Private Instance Methods
component_xml()
click to toggle source
# File lib/sfc.rb, line 31 def component_xml load.css(ELEMENTS[:component]).first end
load()
click to toggle source
# File lib/sfc.rb, line 27 def load Oga.parse_xml File.open @path end
reduce_whitespace(text)
click to toggle source
# File lib/sfc.rb, line 23 def reduce_whitespace(text) text.gsub(/\s+/, " ") end
render(type)
click to toggle source
# File lib/sfc.rb, line 35 def render(type) Element.new(@xml, type).render end