Class: HandlebarsAssets::HandlebarsTemplate::TemplatePath

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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ TemplatePath

Returns a new instance of TemplatePath.



143
144
145
# File 'lib/handlebars_assets/handlebars_template.rb', line 143

def initialize(path)
  @full_path = path
end

Instance Method Details

#is_ember?Boolean

Returns:

  • (Boolean)


177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/handlebars_assets/handlebars_template.rb', line 177

def is_ember?
  result = false
  ::HandlebarsAssets::Config.ember_extensions.each do |ext|
    if ext.start_with? '.'
      ext = '\\#{ext}'
      result ||= !(@full_path =~ /#{ext}(\..*)*$/).nil?
    else
      result ||= !(@full_path =~ /\.#{ext}(\..*)*$/).nil?
    end
  end
  result
end

#is_haml?Boolean

Returns:

  • (Boolean)


147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/handlebars_assets/handlebars_template.rb', line 147

def is_haml?
  result = false
  ::HandlebarsAssets::Config.hamlbars_extensions.each do |ext|
    if ext.start_with? '.'
      ext = '\\#{ext}'
      result ||= !(@full_path =~ /#{ext}(\..*)*$/).nil?
    else
      result ||= !(@full_path =~ /\.#{ext}(\..*)*$/).nil?
    end
  end
  result
end

#is_partial?Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/handlebars_assets/handlebars_template.rb', line 173

def is_partial?
  @full_path.gsub(%r{.*/}, '').start_with?('_')
end

#is_slim?Boolean

Returns:

  • (Boolean)


160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/handlebars_assets/handlebars_template.rb', line 160

def is_slim?
  result = false
  ::HandlebarsAssets::Config.slimbars_extensions.each do |ext|
    if ext.start_with? '.'
      ext = '\\#{ext}'
      result ||= !(@full_path =~ /#{ext}(\..*)*$/).nil?
    else
      result ||= !(@full_path =~ /\.#{ext}(\..*)*$/).nil?
    end
  end
  result
end

#nameObject



190
191
192
# File 'lib/handlebars_assets/handlebars_template.rb', line 190

def name
  template_name
end