Sha256: 0d1a46e761a0030197f6d5fedeab89358fc1b4cb7b68e6fe5cbad31f0ff0f9e9
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true require "pathname" module ThemeCheck class Template attr_reader :path def initialize(path, root) @path = Pathname(path) @root = Pathname(root) end def relative_path @path.relative_path_from(@root) end def name relative_path.sub_ext('').to_s end def template? name.start_with?('templates') end def section? name.start_with?('sections') end def snippet? name.start_with?('snippets') end def source @source ||= @path.read end def lines @lines ||= source.split("\n") end def excerpt(line) lines[line - 1].strip end def full_line(line) lines[line - 1] end def parse @ast ||= self.class.parse(source) end def warnings @ast.warnings end def root parse.root end def ==(other) other.is_a?(Template) && @path == other.path end def self.parse(source) Liquid::Template.parse( source, line_numbers: true, error_mode: :warn, ) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
theme-check-0.1.2 | lib/theme_check/template.rb |
theme-check-0.1.1 | lib/theme_check/template.rb |
theme-check-0.1.0 | lib/theme_check/template.rb |