Class: Spree::EmailTemplates::Check

Inherits:
Object
  • Object
show all
Defined in:
app/services/spree/email_templates/check.rb

Overview

Renders a draft the way customers would receive it, with sample data and strict variables, and reports what stops it from rendering. A draft of the layout or a shared partial is checked inside every editable email, since all of them use it, and in every language the store has published its own version of an email in.

An email the store has no record for cannot be rendered with data; its draft is still checked for Liquid syntax errors.

Instance Method Summary collapse

Constructor Details

#initialize(store:, draft:) ⇒ Check

Returns a new instance of Check.

Parameters:



14
15
16
17
# File 'app/services/spree/email_templates/check.rb', line 14

def initialize(store:, draft:)
  @store = store
  @draft = draft
end

Instance Method Details

#call ⇒ Array<Hash>

Returns one { email:, message:, line: } per problem; empty when the draft renders.

Returns:

  • (Array<Hash>) —

    one { email:, message:, line: } per problem; empty when the draft renders



20
21
22
# File 'app/services/spree/email_templates/check.rb', line 20

def call
  locales.flat_map { |locale| email_keys.filter_map { |email_key| problem_in(email_key, locale) } }.uniq
end