Creating an HTML version out of the Powrzilla Template
In this documentation, we will guide you through the process of creating an Powrzilla HTML default template.
If you want to create a email template out of the powrzilla.
Step 1: Create a New App​
Start by creating a new app in Powrzilla.
- Create a new app that support Powrzilla templates.
Step 2: Creating a Template​
- Open the Powrzilla (from app settings).
- Copy the
app_idortemplate_idin the URL. - Modify template and save.
Step 3: Checking the Template​
- Verify that the template has been successfully created.
- Ensure that the template meets your requirements.
Step 4: Creating an HTML Version​
- Create an
.htmlfile in the folder:app/views/user_mailer/test_default.html. - Copy the file path for future reference (for this example it is:
app/views/user_mailer/test_default.html). - Open the Rails console.
Step 5: Retrieving the App and Template​
- Find the app corresponding to the template using the Rails console (we copied it on Step 2)
# Find the app or the template that we have created locally.
# After executing the line below, it will show all the template ids that relates to this app.
# Copy the template id.
App.find(your_app_id).powrzilla_template_ids
# Find the template
powrzilla_email = PowrzillaEmail.find(template_id)
- Verify that the app contains an HTML content.
# We should **NOT** expect `nil`
powrzilla_email.content["html"]
Step 6: Writing the Content​
- Use the
File.openfunction to open the file for writing.
# We are going to use the `path` that we copied before (Step 4)
file = File.open("app/views/user_mailer/test_default.html", "w")
# Why are we using `File.open` and not just copying from console?
# It takes your time to copy from console.
- Write the content of the your
PowrzillaEmailtemplate to thehtmlfile.
file.write(powrzilla_email.content["html"])
- Ensure that the content is saved correctly.
Step 7: Calling the Template​
- Use the code below to call the template.
# It will render the whole html file into one string.
# THE `app/views` parts were removed because in the container it has different start of the path.
my_html_template = ActionController::Base.new.render_to_string "/user_mailer/test_default.html"
By following these steps, you can create an Powrzilla HTML default template.