Method: Mandrill::Templates#render

Defined in:
lib/mandrill/api.rb

#render(template_name, template_content, merge_vars = nil) ⇒ Hash

Inject content and optionally merge fields into a template, returning the HTML that results

Parameters:

  • template_name (String)

    the immutable name of a template that exists in the user’s account

  • template_content (Array)

    an array of template content to render. Each item in the array should be a struct with two keys - name: the name of the content block to set the content for, and content: the actual content to put into the block

    • Hash

      template_content[] the injection of a single piece of content into a single editable region

      - [String] name the name of the mc:edit editable region to inject into
      - [String] content the content to inject
      
  • merge_vars (Array) (defaults to: nil)

    optional merge variables to use for injecting merge field content. If this is not provided, no merge fields will be replaced.

    • Hash

      merge_vars[] a single merge variable

      - [String] name the merge variable's name. Merge variable names are case-insensitive and may not start with _
      - [String] content the merge variable's content
      

Returns:

  • (Hash)

    the result of rendering the given template with the content and merge field values injected

    • String

      html the rendered HTML as a string



215
216
217
218
# File 'lib/mandrill/api.rb', line 215

def render(template_name, template_content, merge_vars=nil)
    _params = {:template_name => template_name, :template_content => template_content, :merge_vars => merge_vars}
    return @master.call 'templates/render', _params
end