Class: Crm::TemplateSet
- Inherits:
-
Core::BasicResource
- Object
- Core::BasicResource
- Crm::TemplateSet
- Defined in:
- lib/crm/template_set.rb
Overview
TemplateSet
represents the JustRelate WebCRM template set singleton. The templates of the template set singleton can be used to render customized text, e.g. a mailing greeting or a password request email body (password_request_email_body
).
JustRelate WebCRM uses the / Liquid template engine for evaluating the templates.
Class Method Summary collapse
- .path ⇒ Object
-
.singleton ⇒ TemplateSet
Returns the template set singleton.
Instance Method Summary collapse
-
#render_preview(templates: {}, context: {}) ⇒ Hash{String => String}
Renders a preview of the template set using the specified context items.
-
#update(attributes) ⇒ self
Updates the attributes of this template set.
Methods included from Core::Mixins::Inspectable
Methods included from Core::Mixins::ChangeLoggable
Methods inherited from Core::BasicResource
base_type, #eql?, #id, #path, #reload, resource_name, #type
Methods included from Core::Mixins::AttributeProvider
#[], #attributes, #initialize, #method_missing, #methods, #raw, #respond_to_missing?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Crm::Core::Mixins::AttributeProvider
Class Method Details
.path ⇒ Object
13 14 15 |
# File 'lib/crm/template_set.rb', line 13 def self.path resource_name end |
.singleton ⇒ TemplateSet
Returns the template set singleton.
20 21 22 |
# File 'lib/crm/template_set.rb', line 20 def self.singleton new({}).reload end |
Instance Method Details
#render_preview(templates: {}, context: {}) ⇒ Hash{String => String}
Renders a preview of the template set using the specified context items. This is for testing your (future) templates.
-
All templates contained in the set are rendered.
-
You may temporally add any number of
templates
to the set (just for the purpose of rendering). -
Pass as
context
items all the instances (e.g. contact, acticity) for which the templates should be rendered.
Templates have access to the context items. You can use the following keys to represent context items:
-
account
-
contact
-
activity
-
mailing
-
event
The keys expect an ID as input. For example, {"account" => "23"}
allows the template to access account.name
of the account with the ID 23
.
74 75 76 77 78 79 |
# File 'lib/crm/template_set.rb', line 74 def render_preview(templates: {}, context: {}) Core::RestApi.instance.post("#{path}/render_preview", { 'templates' => templates, 'context' => context, }) end |
#update(attributes) ⇒ self
Updates the attributes of this template set. See Modifiable#update for details.
28 29 30 31 |
# File 'lib/crm/template_set.rb', line 28 def update(attributes) load_attributes( Core::RestApi.instance.put(path, attributes, if_match_header)) end |