Module: Card::Set::All::Haml::Format

Extended by:
Card::Set::AbstractFormat
Includes:
Format::HamlPaths
Defined in:
tmpsets/set/mod003-core/all/haml.rb

Constant Summary

Constants included from Format::HamlPaths

Format::HamlPaths::TEMPLATE_DIR

Instance Method Summary collapse

Methods included from Format::HamlPaths

#deep_source, #each_template_path, #haml_block_locals, #haml_template_path, #haml_to_html, #template_location, #try_haml_template_path, #with_template_path

Instance Method Details

#haml(*args, &block) ⇒ String

Renders haml templates. The haml template can be passed as string or block or a symbol that refers to a view template.

Examples:

render a view template

# view/type/basic/my_template.haml:
%p
  Hi
  = name

# set/type/basic.rb:
view :my_view do
  haml :my_template, name: "Joe:  # => "<p>Hi Joe<p/>"
end

use a block to pass haml

haml name: "Joe" do
  <<-HAML.strip_heredoc
    %p
      Hi
      = name
  HAML
# => <p>Hi Joe</p>

create a slot in haml code

- haml_wrap do
  %p
    some haml

Parameters:

  • args (Hash, String, Symbol)

    If a symbol is given then a template is expected in the corresponding view directory.

Returns:

  • (String)

    rendered haml as HTML



48
49
50
51
52
53
54
# File 'tmpsets/set/mod003-core/all/haml.rb', line 48

def haml *args, &block
  if args.first.is_a? Symbol
    process_haml_template(*args)
  else
    process_haml(*args, &block)
  end
end

#haml_partial(partial, locals = {}) ⇒ Object



56
57
58
59
# File 'tmpsets/set/mod003-core/all/haml.rb', line 56

def haml_partial partial, locals={}
  locals[:template_path] ||= @template_path
  process_haml_template "_#{partial}".to_sym, locals
end