Sha256: 659f000d6b014bd4971a77d3edd2e53ff59bf883e83cfd01b9cb1c40d16c335c

Contents?: true

Size: 765 Bytes

Versions: 2

Compression:

Stored size: 765 Bytes

Contents

module VueCK
    class Element    
        def initialize(doc, type)
            @node = doc.css(ELEMENTS[type])
            @type = type
            verify
        end

        def verify
            return unless REQUIRED[@type]
            raise ComonentRenderError if @node.empty?
        end

        def lang
            @node.attribute(ATTRIBUTES[:lang]).first.value || LANG_DEFALTS[type]
        end

        def empty?
            @node.empty?
        end

        def text
            @node.first.children.text
        end

        def render
            return text if lang == LANG_DEFALTS[:script]
            raise InvalidTemplateEngine unless Tilt[lang]
            Tilt[lang].new { text }.render
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vueck-1.0.1 lib/element.rb
vueck-1.0.0 lib/element.rb