Class: HandlebarsAssets::HandlebarsRenderer::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.



206
207
208
# File 'lib/handlebars_assets/handlebars_template.rb', line 206

def initialize(path)
  @full_path = path
end

Instance Method Details

#check_extension(ext) ⇒ Object



210
211
212
213
214
215
216
217
218
219
# File 'lib/handlebars_assets/handlebars_template.rb', line 210

def check_extension(ext)
  result = false
  if ext.start_with? '.'
    ext = "\\#{ext}"
    result ||= !(@full_path =~ /#{ext}(\..*)*$/).nil?
  else
    result ||= !(@full_path =~ /\.#{ext}(\..*)*$/).nil?
  end
  result
end

#is_ember?Boolean

Returns:

  • (Boolean)


237
238
239
240
241
242
243
# File 'lib/handlebars_assets/handlebars_template.rb', line 237

def is_ember?
  result = false
  ::HandlebarsAssets::Config.ember_extensions.each do |ext|
    result ||= check_extension(ext)
  end
  result
end

#is_haml?Boolean

Returns:

  • (Boolean)


221
222
223
224
225
226
227
# File 'lib/handlebars_assets/handlebars_template.rb', line 221

def is_haml?
  result = false
  ::HandlebarsAssets::Config.hamlbars_extensions.each do |ext|
    result ||= check_extension(ext)
  end
  result
end

#is_partial?Boolean

Returns:

  • (Boolean)


245
246
247
# File 'lib/handlebars_assets/handlebars_template.rb', line 245

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

#is_slim?Boolean

Returns:

  • (Boolean)


229
230
231
232
233
234
235
# File 'lib/handlebars_assets/handlebars_template.rb', line 229

def is_slim?
  result = false
  ::HandlebarsAssets::Config.slimbars_extensions.each do |ext|
    result ||= check_extension(ext)
  end
  result
end

#nameObject



249
250
251
# File 'lib/handlebars_assets/handlebars_template.rb', line 249

def name
  template_name
end