-
-
Save pablojimeno/c1eb40d74e86e7e3ceb872932dfbfcdc to your computer and use it in GitHub Desktop.
Create and send a Mailchimp campaign with gibbon, using content sections from ActionView templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gibbon = Gibbon::API.new | |
view = ActionView::Base.new('app/views/', {instance_variable_for_templates: 5324}, ActionController::Base.new) | |
campaign = gibbon.campaigns.create( | |
type: "regular", | |
options: { | |
list_id: 'xxxy', | |
from_email: 'you@example.com', | |
from_name: 'Your From', | |
subject: "the subject", | |
template_id: 128128398 | |
}, | |
content: { | |
sections: { | |
template_html: view.render(partial: 'mailchimp/template_html'), | |
footer_or_whatever: view.render(partial: 'mailchimp/footer_or_whatever') | |
} | |
} | |
) | |
gibbon.campaigns.send(cid: campaign['id']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- create a 'code your own' template --> | |
<!-- drag & drop / WYSIWYG templates made by mailchimp don't support adding mc:edit blocks --> | |
<!-- the WYSIWYG editor can only be used by campaigns created through the mailchimp.com GUI, not via the API --> | |
<html> | |
<div mc:edit='template_html'>placeholder text</div> | |
<div mc:edit='footer_or_whatever'>placeholder text that only appears when footer_or_whatever is not provided (or in preview mode) </div> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment