Mailjet templating language(TWIG, PUG syntax) - how to use template variable within inline style prop? - django-templates

I'm trying to customize my e-mail templates using the Mailjet Passport tool. The HTML code generated by Passport Drag and Drop tool, supports templating language that is similiar to Twig.
What I need to achieve is to put variable for inline style property like on the code example below:
<span
style="color: {{var: PARTNER_COLOR:"#d2d2d2"}};" // it does not work
>
Lorem ipsum {{var:PARTNER_NAME:"Default Partner"}}.mywebstite.de <!-- this work as expected -->
</span>
Interpolating the {{var:VARIABLE_NAME}} within inner HTML content or for src attribute works as expected, but I'm not able to figure out how to use them with the style attribute.
Maybe there is some other solution for dynamically changing color values for css color, background properties in my e-mail templates?
Docs are very poor to be honest, but here is the reference: Maijlet Templating Language Docs

After couple of days I have finally found and answer.
For anyone looking for this in the future there can't be any space sign before the curly braces and var declaration like in the example below:
BAD:
<span
style="color: {{var: PARTNER_COLOR:"#d2d2d2"}};" // it does not work
>
Lorem ipsum {{var:PARTNER_NAME:"Default Partner"}}.mywebstite.de <!-- this work as expected -->
</span>
GOOD:
<span
style="color:{{var:PARTNER_COLOR:"#d2d2d2"}};" // THIS WORKS!
>
Lorem ipsum {{var:PARTNER_NAME:"Default Partner"}}.mywebstite.de <!-- this work as expected -->
</span>

Related

Unable to loop through navigable string with BeautifulSoup CSS Selector

I would like to extract the content inside the p tag below.
<section id="abstractSection" class="row">
<h3 class="h4">Abstract<span id="viewRefPH" class="pull-right hidden"></span>
</h3>
<p> Variation of the (<span class="ScopusTermHighlight">EEG</span>), has functional and. behavioural effects in sensory <span class="ScopusTermHighlight">EEG</span We can interpret our. Individual <span class="ScopusTermHighlight">EEG</span> text to extract <span class="ScopusTermHighlight">EEG</span> power level.</p>
</section>
A one line Selenium as below,
document_abstract = WebDriverWait(self.browser, 20).until(
EC.visibility_of_element_located((By.XPATH, '//*[#id="abstractSection"]/p'))).text
can extract easily the p tag content and provide the following output:
Variation of the EEG, has functional and. behavioural effects in sensoryEEG. We can interpret our. Individual EEG text to extract EEG power level.
Nevertheless, I would like to employ the BeautifulSoup due to speed consideration.
The following bs by referring to the css selector (i.e.,#abstractSection ) was tested
url = r'scopus_offilne_specific_page.html'
with open(url, 'r', encoding='utf-8') as f:
page_soup = soup(f, 'html.parser')
home=page_soup.select_one('#abstractSection').next_sibling
for item in home:
for a in item.find_all("p"):
print(a.get_text())
However, the compiler return the following error:
AttributeError: 'str' object has no attribute 'find_all'
Also, since Scopus require login id, the above problem can be reproduce by using the offline html which is accessible via this link.
May I know where did I do wrong, appreciate for any insight
Thanks to this OP, the problem issued above apparently can be solve simply as below
document_abstract=page_soup.select('#abstractSection > p')[0].text

TYPO render section inside a section

I am trying to place the logo in the middle of my navigation.
<f:section name="MainNavigation">
<f:if condition="{menu}">
<ul class="navbar-nav">
<f:for each="{menu}" as="item">
<f:if condition="{item.spacer}">
<f:then>
</ul>
<f:render section="MainNavigationLogo" arguments="{_all}" />
<ul class="navbar-nav">
</f:then>
<f:else>
The menu is splitting up, but the logo doesn't show up. I think it is because that {_all} does not contain the right information.
The MainNavigation is rendered this way
<f:render section="MainNavigation" arguments="{menu: mainnavigation, theme: theme}" />
How can I render af section inside another section in TYPO3?
There are no restriction to calls of sections in sections. But you need to provide the neccessary data.
As you wrote your prime section call just got two variables menu and theme, so other variables are not know inside the section, and could not be transfered any further.
You can test your set of variables by inserting this viewhelper call at different lines of your template:
<f:debug titel="identify this call">{_all}</f:debug>
Use the title attribute to provide a unique identifier of this debug code.
You might need to add another variable to your primary call so the infrmation also is available in your MainNavigationLogo section.

How to include a checkbox image in a Qweb Report?

Is there way to change checkbox image in qweb report. For example i want to change standard "V" to image like this:
Is it possible?
Solution 0
Add the file to your module, for example store it in the path /module_name/static/src/img/image_name.png
Then now you can add the image to the Qweb Report:
<img t-att-src="'/module_name/static/src/img/image_name.png'" />
Note: respect the order and the type of the quotes
Solution 1
Maybe it is useful to create ul html list with all the elements you want to add:
<style>
.icon_list {
list-style-image: url('/module_name/static/src/img/image_name.png');
}
</style>
<!-- [...] -->
<ul class="icon_list" >
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
(I didn´t try it but it should work as well)
you can simply replace it with the standard Unicode character ☑ by a field that is checking the status
Please use "input type as checkbox". It worked for me.
<input type="checkbox" checked="checked"/>I agree that glasses are selected based on my indications
in odoo11
you can choose this class for checkbox
i class="fa fa-check which opening and closing tags This gives better checkbox than default in odoo

Add custom fields for use in template

Currently custom fields show up as text on product pages.
Custom Field #1 Name: Material, Custom Field #1 Value: Cotton
Is there some other option instead to just pass data to the template? For example I'd like to display a 'NEW' label on the product page if new == true.
Sort of like https://springmerchant.com/bigcommerce/product-labels/
Right now we're using handlebars and if-statements to hide custom fields with a __prefix. For example __new: true.
If you're developing your template in stencil, there are a couple of options... You can loop through the custom fields until you find the correct one and then check the value... Ex:
{{#each product.custom_fields}}
{{#if name "==" "__new"}}
{{#if value "==" "true"}}
YOUR HTML CODE HERE
{{/if}}
{{/if}}
{{/each}}
Alternatively, you can put all your custom_fields into an array and use javascript to populate various aspects of the site:
<script>
var custom = [];
{{#each product.custom_fields}}
custom.push({'name':"{{name}}",'value':"{{value}}"});
{{/each}}
YOUR CODE TO LOOP THROUGH JSON ARRAY AND DO VARIOUS TESTS AND STUFF
</script>
If you don't have access to stencil templates and are just doing development through the control panel, you could write javascript to parse the default custom_field html and then use the data accordingly.
None of the solutions are particularly clean, but they all work.

Issue faced in rendering FTL code in <form-list> after updating moqui

After the recent updates in Moqui I am facing a problem in rendering the FTL code using <render-mode> tag.
Let me try to explain the problem,
Earlier I have rendered the FTL code using <render-mode> in <form-list> tag it was working properly but when I took the update of Moqui, it is displaying the whole FTL code written in the tag on browser.
Also after the update of Moqui when I use the same code outside the <form-list>, it is working as expected.
Is this the desired behavior or we should do some changes at framework level.
Below is the sample code for the same.
<form-list name="demoName" list="nameList" >
<field name="name">
<default-field title="Name">
<render-mode>
<text><![CDATA[
<#if name=='Demo Name 1'>
<span class="label label-success">Demo Name 1</span>
<#elseif name=='Demo Name 2'>
<span class="label label-info">Demo Name 2</span>
</#if>
]]></text>
</render-mode>
</default-field>
</field>
</form-list>
This is how the code is being rendered on the screen at revision #891b4d5.
This was the output that we used to get in Moqui revision #983a9e1
Can we use render-mode in form-list the way we are using it in the above code snippet?
For proper usage of the render-mode.text element you should specify a text.#type attribute. It defaults to "all" so the text will be used for all types, but your content contains HTML so it should have text.#type=html.
Still, what you include should work fine. Here is an example from the apps.xml screen in the latest version of Moqui (in the git repo) that runs with every apps screen render and works with interpretation of the inline text as a template:
<render-mode><text type="html"><![CDATA[
<#assign footerItemList = sri.getThemeValues("STRT_FOOTER_ITEM")>
<div id="apps-footer-content">
<#list footerItemList! as footerItem>
${footerItem}
</#list>
</div>
]]></text></render-mode>