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

#check_extension(ext) ⇒ Object



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

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)


174
175
176
177
178
179
180
# File 'lib/handlebars_assets/handlebars_template.rb', line 174

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

#is_haml?Boolean

Returns:

  • (Boolean)


158
159
160
161
162
163
164
# File 'lib/handlebars_assets/handlebars_template.rb', line 158

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

#is_partial?Boolean

Returns:

  • (Boolean)


182
183
184
# File 'lib/handlebars_assets/handlebars_template.rb', line 182

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

#is_slim?Boolean

Returns:

  • (Boolean)


166
167
168
169
170
171
172
# File 'lib/handlebars_assets/handlebars_template.rb', line 166

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

#nameObject



186
187
188
# File 'lib/handlebars_assets/handlebars_template.rb', line 186

def name
  template_name
end