Module: Landline::DSL::TemplateMethods

Included in:
TemplateContext
Defined in:
lib/landline/dsl/methods_template.rb

Overview

Common methods for template contexts

Instance Method Summary collapse

Instance Method Details

#import(filepath) ⇒ String

(in Landline::Template context) Import a template part

Parameters:

  • filepath (String, File)

    path to the file (or the file itself)

Returns:

  • (String)

    compiled template



14
15
16
17
18
19
20
21
22
23
# File 'lib/landline/dsl/methods_template.rb', line 14

def import(filepath)
  template = if filepath.is_a? File
               filepath
             elsif filepath.start_with? "/"
               File.open(filepath)
             else
               file(filepath)
             end
  @parent_template.import(template).run
end