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.



202
203
204
# File 'lib/handlebars_assets/handlebars_template.rb', line 202

def initialize(path)
  @full_path = path
end

Instance Method Details

#check_extension(ext) ⇒ Object



206
207
208
209
210
211
212
213
214
215
# File 'lib/handlebars_assets/handlebars_template.rb', line 206

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)


233
234
235
236
237
238
239
# File 'lib/handlebars_assets/handlebars_template.rb', line 233

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

#is_haml?Boolean

Returns:

  • (Boolean)


217
218
219
220
221
222
223
# File 'lib/handlebars_assets/handlebars_template.rb', line 217

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

#is_partial?Boolean

Returns:

  • (Boolean)


241
242
243
# File 'lib/handlebars_assets/handlebars_template.rb', line 241

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

#is_slim?Boolean

Returns:

  • (Boolean)


225
226
227
228
229
230
231
# File 'lib/handlebars_assets/handlebars_template.rb', line 225

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

#nameObject



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

def name
  template_name
end