Is that some tips to write dustjs template for faster render? node.js - node.js

I use dustjs to render my mail content and I found that it's slow when render some bigger templates. Is any tips when write dustjs template to increase the render speed, or some good practice?
details:
my template consists of several components (more than 5), each component if different from others, there is one example of the component as follow:
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF">
<table cellpadding="0" cellspacing="0" width="650">
<tr>
<td align="center">
<table width="590" border="0" cellspacing="0" cellpadding="0">
{#eq key=haveBanner value=1}
<tr>
<td height="105" align="center" valign="middle">
<img src="{bannerUrl|pictureUrl}" width="590" border="0">
</td>
</tr>
{:else}
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0" width="590" height="75" style="border-top:solid 3px #343434">
<tr>
<td width="130" align="left" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" height="55">
<img src="{sellerLogo|pictureUrl}" width="110" height="55">
</td>
</tr>
</table>
</td>
<td width="460" align="left">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"><font style="font-family:arial;font-size:16px;color:#292929">{compName}</strong></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
{/eq}
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" style="border:solid 1px #dbdbdb" width="594">
<tr>
<td width="149" valign="top" style="border-right:solid 1px #dbdbdb">
<table width="146" cellspacing="0" cellpadding="0">
<tr>
{#eq key=selectedProductFlag value=1}
<td height="80" style="padding:20px 20px"><font style="font-family:arial;font-size:18px;color:#333333"><b>Promotion Products</b></font></td>
{:else}
<td height="80" style="padding:20px 20px"><font style="font-family:arial;font-size:18px;color:#333333"><b>Promotion Products</b></font></td>
{/eq}
</tr>
<tr>
<td align="center" height="26" valign="top">
<table width="119" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="border-top:solid 1px #e5e5e5"><img src="http://newimg.globalmarket.com/PA/edm/images/spacer.gif" height="1" width="1"></td>
</tr>
</table>
</td>
</tr>
{#finalProdGroupList}
<tr>
<td height="35" valign="top">
<table width="146" cellspacing="0" cellpadding="0">
<tr>
<td style="padding-left:25px"><font style="font-family:arial;font-size:12px;color:#484848">{prodGroupName}</font></td>
</tr>
</table>
</td>
</tr>
{/finalProdGroupList}
</table>
</td>
<td width="443" valign="top">
<table width="442" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="442" border="0" cellspacing="0" cellpadding="0" height="255">
<tr>
{#secondaryProducts}
{#productList spIdx=$idx}
{#eq key=$idx value=2}
<td align="center" valign="top" width="147">
{:else}
<td align="center" valign="top" style="border-right:solid 1px #dbdbdb" width="147">
{/eq}
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="146" align="center">
<img src="{photoUrl|pictureUrl}" border="0" width="126" height="126" alt="{fullProdName}">
</td>
</tr>
<tr>
<td align="center">
<table width="126" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0" width="126">
<tr>
<td align="left" height="33" valign="top" style="line-height:15px">
<font style="font-family:Arial;font-size:12px;color:#333333">{productName}</font>
</td>
</tr>
<tr>
<td align="left" height="20" valign="middle"><font style="font-family:Arial;font-size:12px;color:#999999">{certification}</font></td>
</tr>
<tr>
{#eq key=payForInqFlag value=1}
<td align="left" height="35" valign="middle"><img src="http://newimg.globalmarket.com/PA/edm/images/getprice2.png" width="128" height="25"></td>
{:else}
<td align="left" height="35" valign="middle"><img src="http://newimg.globalmarket.com/PA/edm/images/getprice2.png" width="128" height="25"></td>
{/eq}
</tr>
<tr>
<td height="7"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
{/productList}
{/secondaryProducts}
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>

Your problem is very likely the large amount of Dust filters you are using.
Example:
&{trackCodeData|gaTrackCode|dbTrackCode|entityId|entityType|edmpid|recId|userId|token|final}
Some of these filters are even being run in a loop. It looks like you are running well over 100 filters per render of this template. Filters are executed synchronously and serially, so Dust can't continue to render the template until the filter is done.
Without knowing what these filters do, it's hard to make specific recommendations about the filters themselves. However, you seem to use the same filters multiple times to output the same data. If possible, you should pregenerate this data and add it into the context instead of dynamically generating it.
You can gain a few more cycles by turning on whitespace compression, if you have it turned off:
dust.config.whitespace = false;
But Dust intrinsically is very fast. Without your filters, your template renders in around 3ms for me.

Related

Need the full correct html code for this Table

Image table
Please write full html codes for this table. You may see the Table image from above via the link.
<table border="1" width="800">
<tr>
<th>Level1</th>
<th>Level2</th>
<th>Level2</th>
<th>Info</th>
<th>Name</th>
</tr>
<tr>
<td rowspan="6">System</td>
</tr>
<tr>
<td rowspan="4">System Apps</td>
<td rowspan="2">System Memory</td>
</tr>
<tr>
<td rowspan="3">SystemEnv</td>
<td rowspan="1">SystemEnv2</td>
<td rowspan="2">Memeory Test</td>
</tr>
Here is the table code :
<table border="2">
<tr>
<th>Level 1</th>
<th>Level 2</th>
<th>Level 3</th>
<th>info</th>
<th>Name</th>
</tr>
<tr>
<td rowSpan="6">System</td>
<td rowSpan="4">System apps</td>
<td rowSpan="3">SystemEnv</td>
<td>App Text</td>
<td>foo</td>
</tr>
<tr>
<td>App memory</td>
<td>foo</td>
</tr>
<tr>
<td>App test</td>
<td>bar</td>
</tr>
<tr>
<td>Systemenv2</td>
<td>App test</td>
<td>bar</td>
</tr>
<tr>
<td rowSpan="2">System Memory</td>
<td rowSpan="2">Memory test</td>
<td>memory func</td>
<td>foo</td>
</tr>
<tr>
<td>Memory Func</td>
<td>foo</td>
</tr>
</table>

How to pass product TVs to SimpleCart's scGetCart snippet?

I need some TVs (weight, dimensions, etc) I've associated with my products to appear in the Cart page of my SimpleCart site.
Problem is I have no idea how to do this. I don't understand how the SimpleCart cart is built and there isn't documentation for this.
Would anyone know how I can show TVs associated with each product in the cart output chunk?
The cart snippet has the following code which gets data from the cart and puts it into Chunks:
$sc = $modx->getService('simplecart','SimpleCart',$modx->getOption('simplecart.core_path',null,$modx->getOption('core_path').'components/simplecart/').'model/simplecart/',$scriptProperties);
if (!($sc instanceof SimpleCart)) return '';
 
$controller = $sc->loadController('Cart');
$output = $controller->run($scriptProperties);
The output Chunk looks like:
<div id="simplecart">
<form action="[[~[[*id]]]]" method="post" id="form_cartoverview">
<input type="hidden" name="updatecart" value="true" />
<table>
<tr>
<th class="desc">[[%simplecart.cart.description]]</th>
<th class="price">[[%simplecart.cart.price]]</th>
<th class="quantity">[[%simplecart.cart.quantity]]</th>
[[+cart.total.vat_total:notempty=`<th class="quantity">[[%simplecart.cart.vat]]</th>`:isempty=``]]
<th class="subtotal">[[%simplecart.cart.subtotal]]</th>
<th> </th>
</tr>
[[+cart.wrapper]]
[[+cart.total.discount:notempty=`<tr class="total first discount">
<td colspan="[[+cart.total.vat_total:notempty=`3`:isempty=`2`]]"> </td>
<td class="label">[[%simplecart.cart.discount]]</td>
<td class="value">- [[+cart.total.discount_formatted]]</td>
<td class="extra">[[+cart.total.discount_percent:notempty=`([[+cart.total.discount_percent]]%)`:isempty=` `]]</td>
</tr>`:isempty=``]]
[[+cart.total.vat_total:notempty=`
<tr class="total [[+cart.total.discount:notempty=`second`:isempty=`first`]]">
<td colspan="3"> </td>
<td class="label">[[%simplecart.cart.total_ex_vat]]</td>
<td class="value">[[+cart.total.price_ex_vat_formatted]]</td>
<td class="extra"> </td>
</tr>
[[+cart.vat_rates]]
<tr class="total [[+cart.total.discount:notempty=`third`:isempty=`second`]]">
<td colspan="3"> </td>
<td class="label">[[%simplecart.cart.total_vat]]</td>
<td class="value">[[+cart.total.vat_total_formatted]]</td>
<td class="extra"> </td>
</tr>
<tr class="total [[+cart.total.discount:notempty=`fourth`:isempty=`third`]]">
<td colspan="3"> </td>
<td class="label">[[%simplecart.cart.total_in_vat]]</td>
<td class="value">[[+cart.total.price_formatted]]</td>
<td class="extra"> </td>
</tr>
`:isempty=`
<tr class="total [[+cart.total.discount:notempty=`second`:isempty=`first`]]">
<td colspan="2"> </td>
<td class="label">[[%simplecart.cart.total]]</td>
<td class="value">[[+cart.total.price_formatted]]</td>
<td class="extra"> </td>
</tr>
`]]
</table>
<div class="submit">
<input type="submit" value="[[%simplecart.cart.update]]" />
</div>
</form>
This does appear to be documented:
Product Options (TVs)
and to output them:
Modifying the Product Template
It appears that you would just output them normally [[*myProductOptions]]
Though, it appears that your template is using a placeholder, I would try
[[+cart.myProductOptions] as well. If all else fails you might try debugging the simplecart class and dump the array of product data before it populates the chunk, there might be a clue in there.
Found (through trial and error) you must use:
[[+product.tv.name_of_tv]]

why does the Gmail app on iPhone ignore media queries?

I'm putting together an email newsletter for a client, and find that more or less every email client and app provides a more or less readable experience (they still need some work) - except for the Gmail app. Once the breakpoint is reached, it should be displaying as one column. But it does not.
I'm not sure why this is. Is there a way to force the app to display the newsletter in desktop mode shrunken down to fit the screen width? Or is there a way to target Gmail with a conditional so that the content will obey the media query?
Related: the litmus tests I've ran don't look anything at all like the result I'm getting on my iPhone. Why is that?
http://codepen.io/sabaeus/pen/ZGQWdZ?editors=100
This is in my document head:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;">
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" />
<title>Title</title>
</head>
And then this is in my body:
<body>
<!-- background table start -->
<table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="background_table">
<tbody>
<tr>
<td>
<!-- end of background table start -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td style="display:inline-block;" width="100%"><img src="http://placehold.it/197x41" style="display:block;"></td>
</tr>
<tr>
<td width="100%" height="20"> </td>
</tr>
<tr>
<td width="100%" height="100">
<img src="http://placehold.it/699x400" style="display:block;">
</td>
</tr>
<tr>
<td width="100%" height="10"> </td>
</tr>
</tbody>
</table>
<!-- hello/quick links -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="393" class="column" style="height:100%;display:inline-block;margin-right:53px">Hello,
<br>
<br> Intro text
</td>
<td width="230" class="column" style="height:100%;padding:20px;">
<span class="h1">Quick Links</span>
<br>
<br>
<br>
<span style="display:inline-block; padding-bottom:5px;"><strong>Link 1</strong></span>
<br> Info for link 1
<br>
<br>
<span style="display:inline-block; padding-bottom:5px;"><strong>Link 2</strong></span>
<br>Link
<br>
<br>
<span style="display:inline-block; padding-bottom:5px;"><strong>Link 3</strong></span>
<br>Link
</td>
</tr>
</tbody>
</table>
<!-- hello/quick links -->
<!-- marketing communications -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td>
<span class="h1">Headline 1</a>
</td>
</tr>
</tbody>
</table>
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="148" class="column-img" style="height:100%;display:inline-block;margin-right:17px">
<img src="http://placehold.it/148x111" style="display:block;">
</td>
<td width="503" class="column-text-1" style="padding:20px"><span style="font-size:18px;display:inline-block; padding-bottom:5px;"><strong>Sub head</strong></span>
<br>Info info info info info info info info info info info</td>
</tr>
</tbody>
</table>
<!-- marketing communications -->
<!-- new print collateral -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td class="top-buffer">
<span class="h1">Headline 2</span>
</td>
</tr>
</tbody>
</table>
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="148" class="column-img" style="height:100%;display:inline-block;margin-right:17px"><img src="http://placehold.it/148x220" style="display:block;"></td>
<td width="503" class="column-text-1" style="padding:20px"><span style="font-size:18px;display:inline-block; padding-bottom:5px;"><strong>Sub head</strong></span>
<br> info info info info</td>
</tr>
</tbody>
</table>
<!-- new print collateral -->
<!-- advertising -->
<!-- brand ads -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td class="top-buffer">
<span class="h1" style="display:inline-block;">Headline 3</span>
<br>
<span style="font-size:18px;">
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td style="padding-top:0px;">
<span style="font-size:18px;"><strong>Sub head</strong></span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="350" class="column" style="height:100%;margin-right:131px"><img src="http://placehold.it/246x264" style="min-width:350px; display:block;"></td>
<td style="height:100%;" width="350" class="column">
<img src="http://www.placehold.it/267x324" style="min-width:350px; display:block;"></td>
</tr>
</tbody>
</table>
<!-- brand ads -->
<!-- community ads -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td style="padding-top:30px;padding-bottom:0px;">
<span style="font-size:18px;"><strong>Sub head</strong></span>
</td>
</tr>
</tbody>
</table>
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="350" class="column" style="height:100%;margin-right:131px">
<img src="http://placehold.it/197x320" style="min-width:350px; display:block">
<table>
<tbody>
<tr>
<td>
info info info info
</td>
</tr>
</tbody>
</table>
</td>
<td style="height:100%;" width="350" class="column"><img src="http://placehold.it/212x328" style="min-width:350px;display:block">
<table>
<tbody>
<tr>
<td style="padding-top:10px">
<br> info info info info info
</td>
</tr>
</tbody>
</table>
</td>
</td>
</tr>
</tbody>
</table>
<!-- community ads -->
<!-- advertising -->
<!-- talent acquisition -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td class="top-buffer">
<span class="h1">Headline 4</span>
</td>
</tr>
</tbody>
</table>
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<!-- <tr>
<td width="100%" height="10"> </td>
</tr>
-->
<tr>
<td width="100%" height="100">
<a href="#" target="_blank">
<img src="http://placehold.it/668x195" style="width:100%;display:block;"></a>
</td>
</tr>
<tr>
<td width="100%" height="10"> </td>
</tr>
</tbody>
</table>
<!-- text -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
</tr>
<tr>
<td width="100%" height="100">
<span style="font-size:18px;display:inline-block; padding-bottom:5px;"><strong>Sub head</strong></span>
<br>Info info info
</td>
</tr>
<tr>
<td width="100%" height="10"> </td>
</tr>
</tbody>
</table>
<!-- text -->
<!-- talent acquisition -->
<!-- new expert advice -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td class="top-buffer">
<span class="h1">Headline 5</span>
</td>
</tr>
</tbody>
</table>
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td>
<span style="display:inline-block;">Info info info</span>
</td>
</tr>
</tbody>
</table>
<!-- 0 -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="345" class="column" style="height:100%;display:inline-block;margin-right:46px"><img src="http://placehold.it/345x281" style="width:100%;display:block;"></td>
<td width="322" class="column" style="padding:20px;">
<span style="display:inline-block; padding-bottom:5px;"><strong>info info</strong></span>
<br>info info info</td>
</tr>
</tbody>
</table>
<!-- 0 -->
<!-- 1 -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="345" class="column" style="height:100%;display:inline-block;margin-right:46px"><img src="http://placehold.it/345x281" style="width:100%;display:block;"></td>
<td width="322" class="column" style="padding:20px;">
<span style="display:inline-block; padding-bottom:5px;"><strong>info info</strong></span>
<br>info info info</td>
</tr>
</tbody>
</table>
<!-- 1 -->
<!-- 2 -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="345" class="column" style="height:100%;display:inline-block;margin-right:46px"><img src="http://placehold.it/345x281" style="width:100%;display:block;"></td>
<td width="322" class="column" style="padding:20px">
<span style="display:inline-block; padding-bottom:5px;"><strong>info info</strong><span>
<br>
info info info</td>
</tr>
</tbody>
</table>
<!-- 2 -->
<!-- 3 -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="345" class="column" style="height:100%;display:inline-block;margin-right:46px"><img src="http://placehold.it/345x281" style="width:100%;display:block;"></td>
<td width="322" class="column" style="padding:20px;">
<span style="display:inline-block; padding-bottom:5px;"><strong>info info</strong></span>
<br>info info info
</td>
</tr>
</tbody>
</table>
<!-- 3 -->
<!-- new expert advice -->
<!-- epic speaker videos -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td class="top-buffer">
<span class="h1">Headline 6</span>
</td>
</tr>
</tbody>
</table>
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="345" style="height:100%;display:inline-block;margin-right:17px;" class="column"><img src="http://placehold.it/258x154" style="width:100%;display:block;"></td>
<td width="423" class="column" style="padding:20px;">info info info info info</td>
</tr>
</tbody>
</table>
<!-- epic speaker videos -->
<!-- upcoming events -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td class="top-buffer">
<span class="h1">Headline 7</span>
</td>
</tr>
</tbody>
</table>
<table width="800" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<!-- <tr>
<td width="100%" height="10"> </td>
</tr>
-->
<tr>
<td width="100%" height="100">
<span style="font-size:17px"><strong>
May is: Physical Fitness Month / Jewish American Heritage Month</strong></span>
<table>
<tbody>
<tr>
<td>
<ul style="line-height: 150%; width: 582px;">
<li style="list-style-type:none; padding-left:10px;background-color:#ededed">May 10th - <span style="font-weight:300">Mother’s Day</span> </li>
<li style="list-style-type:none;padding-left:10px;">May 25th - <span style="font-weight:300">Memorial Day</span> </li>
<li style="list-style-type:none; padding-left:10px; background-color:#ededed">June 6th - <span style="font-weight:300">D-Day</span></li>
<li style="list-style-type:none;padding-left:10px;">June 14th - <span style="font-weight:300">Flag Day</span></li>
<li style="list-style-type:none; padding-left:10px; background-color:#ededed">June 21st - <span style="font-weight:300">Father’s Day</span></li>
<li style="list-style-type:none;padding-left:10px;">June 21st - <span style="font-weight:300">Alzheimer’s Association Longest day (click below for details)</span></li>
</ul>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td width="100%" height="10"> </td>
</tr>
</tbody>
</table>
<!-- alzheimer's -->
<table width="699" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="100%" height="10"> </td>
</tr>
<tr>
<td width="100%" height="100">
<img src="http://placehold.it/454x174" style="width:100%;display:block;">
</td>
</tr>
<tr>
<td width="100%" height="10"> </td>
</tr>
</tbody>
</table>
<!-- alzheimer's -->
<!-- prior -->
<table width="800" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="100%" height="10"> </td>
</tr>
<tr>
<td width="100%" height="100" style="padding:20px;">
<span style="display:inline-block;padding-bottom:5px">
Info info info
</span>
</td>
</tr>
<tr>
<td width="100%" height="10"> </td>
</tr>
</tbody>
</table>
<!-- prior-->
<!-- upcoming events -->
<!-- footer -->
<table width="600" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<tr>
<td width="100%">
<table width="600" cellpadding="0" cellspacing="0" border="0" align="center" class="body_table">
<tbody>
<!-- Spacing -->
<tr>
<td height="20" style="font-size:1px; line-height:1px; mso-line-height-rule: exactly;"> </td>
</tr>
<!-- Spacing -->
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!-- end of footer -->
<!-- end of background table-->
</td>
</tr>
</tbody>
</table>
</body>
</html>
CSS:
#import url(http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,700);
body {
width: 100% !important;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
margin: 0;
padding: 0;
}
#background_table {
margin: 0;
padding: 0;
width: 100%!important;
line-height: 100%!important;
}
img {
outline: none;
text-decoration: none;
border: none;
-ms-interpolation-mode: bicubic;
max-width: 100%;
height: auto;
display: block;
}
table td {
border-collapse: collapse;
vertical-align: middle;
font-family: 'Open Sans', Trebuchet, sans-serif;
font-size: 17px;
line-height:120%;
color: #000;
}
table td[class="column"] {
height: 100px;
width: 393px;
padding: 15px;
}
table {
border-collapse: collapse;
mso-table-lspace: 0pt;
mso-table-rspace: 0pt;
}
table[class="body_table"] {
width: 699px;
margin-top: 21px;
}
table span[class="h1"] {
font-weight:300;
font-size:35px;
color:#ff9001;
}
table td[class="top-buffer"] {
padding-top: 25px;
}
#media only screen and (max-width: 640px) {
table[class="body_table"] {
width: 600px!important;
}
table td[class="column"] {
width: 100%!important;
display: block!important;
}
table span[class="h1"] {
line-height:110%!important;
font-size:23px!important;
}
*[class="mob-hide"] { display: none !important }
}
Gmail app and Gmail web service strips all class and ID styling out of your style tags. More Info Here
There is an option for some elemental styling in Gmail web service as seen in link above, but other than that you need to do everything inline. This removes the capabilities of responsive design as you cannot inline media queries.
Your best bet is fluid design(percentage based to fit small or large screen) or a mobile first hybrid design that is essentially designed first for Gmail/Outlook and then uses media queries and style tags to make it work for all other email clients.

cellSpace not working in DreamWeaver CS6

I've pasted table code to new div in gridContainer div (using the Fluid Grid Layout option)
Everything seems fine but the cell spacing defined, when I try to change the spacing nothing happens, it keeps it on 0.
Following is the table markup:
<table align="center" cellpadding="0" cellspacing="15">
<col span="7" width="160px" />
<row span="7" width="160px" />
<!---Row 1--->
<tr align="center" height="160px">
<td colspan="2" >
<img src="images/buttons/Optimus.png" />
</td>
<td colspan="2" >
<img src="images/buttons/MapleSim.png">
</td>
<td colspan="2" >
</td>
<td colspan="1" bgcolor="#40b040">
<img src="images/buttons/about_us.png">
</td>
</tr>
<!---Row 2--->
<tr align="center" height="160px">
<td colspan="2" bgcolor="#40b040">
<img src="images/buttons/QFD.white.png">
</td>
<td colspan="1" bgcolor="#cc00cc">
<img src="images/buttons/learning_maple.png">
</td>
<td colspan="3" rowspan="2"
align="left" valign="top" bgcolor="#aaaaff">
<img src="images/buttons/news.png">
News will be shown here
</td>
<td colspan="1" bgcolor="#ff0000">
<img src="images/buttons/services.png">
</td>
</tr>
<!---Row 3--->
<tr align="center" height="160px">
<td colspan="1" bgcolor="#6766cc">
<img src="images/buttons/events.png">
</td>
<td colspan="1" bgcolor="#cccc00">
<img src="images/buttons/forum.png">
</td>
<td colspan="1" bgcolor="#4040ff">
<img src="images/buttons/links.png">
</td>
<td colspan="1" bgcolor="#ffbf00">
<img src="images/buttons/shopping_cart.png">
</td>
</tr>
<!---Row 4--->
<tr align="center" height="160px">
<td colspan="2" bgcolor="#ff0000">
<img src="images/buttons/commercial_users.png">
</td>
<td colspan="1" bgcolor="#ffbf00">
<img src="images/buttons/student_special.png">
</td>
<td colspan="1" bgcolor="#40b000">
<img src="images/buttons/student_special.png">
</td>
<td colspan="1" bgcolor="#ff00cc">
<img src="images/buttons/instruction.png">
</td>
<td colspan="1" bgcolor="#cc00cc">
<img src="images/buttons/learning_maple.png">
</td>
<td colspan="1" bgcolor="#4040ff">
<img src="images/buttons/download.png">
</td>
</tr>
</table>
You can see in this line <table align="center" cellpadding="0" cellspacing="15"> the spacing is 15, but when checking on any browser it shows as it set to 0
Any ideas how to solve it?
Thanks in advance,
Shahar
Ok, I guess I was too hasty.
It appears that the table used two definitions from boilerplate.css
table {
/* [disabled]border-collapse: collapse; */
/* [disabled]border-spacing: 0; */
}
As you can see, simply disabling them resolved the issue.
If there is any other option to override without disabling (maybe usage of !important) I'll be glad to know about it.

graphviz: record node with a bold title

I'm trying to use graphviz to do something similar to UML class diagrams.
I wonder whether there is a way to make a node of style 'register' have its first field in a bold font, to make it different from the other fields.
My node looks like this:
digraph i {
"node" [
label = "<f0> title | <f1> index | ... | <f2> field1 | <f3> field2"
shape = "record"
];
}
I tried this but it doesn't work: (embedding html)
digraph i {
"node" [
label = "<f0> <B>title</B> | <f1> index | ... | <f2> field1 | <f3> field2"
shape = "record"
];
}
I don't believe record-based nodes allow HTML formatting in them. The node shape documentation suggests that record-based nodes have been deprecated in favor of using a none-shaped node with an HTML-like label, which is much more flexible with formatting. These labels are surrounded with <> instead of double quotes.
I haven't been able to test this, but this is close to what you want:
digraph i {
"node" [
label =<<TABLE BORDER="1" CELLBORDER="1" CELLSPACING="0">
<TR><TD PORT="f0"><B>title</B></TD></TR>
<TR><TD PORT="f1">index</TD></TR>
<TR><TD PORT="f2">field1</TD></TR>
<TR><TD PORT="f3">field2</TD></TR>
</TABLE>>
shape = "none"
];
}
Output:
Answering the UML use case more broadly, there is now an official UML example at: https://graphviz.org/Gallery/directed/UML_Class_diagram.html Like https://stackoverflow.com/a/6177064/895245 it uses <b> to make the titles bold:
digraph UML_Class_diagram {
graph [
label="UML Class diagram demo"
labelloc="t"
fontname="Helvetica,Arial,sans-serif"
]
node [
fontname="Helvetica,Arial,sans-serif"
shape=record
style=filled
fillcolor=gray95
]
edge [fontname="Helvetica,Arial,sans-serif"]
edge [arrowhead=vee style=dashed]
Client -> Interface1 [label=dependency]
Client -> Interface2
edge [dir=back arrowtail=empty style=""]
Interface1 -> Class1 [xlabel=inheritance]
Interface2 -> Class1 [dir=none]
Interface2 [label="" xlabel="Simple\ninterface" shape=circle]
Interface1[label = <{<b>«interface» I/O</b> | + property<br align="left"/>...<br align="left"/>|+ method<br align="left"/>...<br align="left"/>}>]
Class1[label = <{<b>I/O class</b> | + property<br align="left"/>...<br align="left"/>|+ method<br align="left"/>...<br align="left"/>}>]
edge [dir=back arrowtail=empty style=dashed]
Class1 -> System_1 [label=implementation]
System_1 [
shape=plain
label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="4">
<tr> <td> <b>System</b> </td> </tr>
<tr> <td>
<table border="0" cellborder="0" cellspacing="0" >
<tr> <td align="left" >+ property</td> </tr>
<tr> <td port="ss1" align="left" >- Subsystem 1</td> </tr>
<tr> <td port="ss2" align="left" >- Subsystem 2</td> </tr>
<tr> <td port="ss3" align="left" >- Subsystem 3</td> </tr>
<tr> <td align="left">...</td> </tr>
</table>
</td> </tr>
<tr> <td align="left">+ method<br/>...<br align="left"/></td> </tr>
</table>>
]
edge [dir=back arrowtail=diamond]
System_1:ss1 -> Subsystem_1 [xlabel="composition"]
Subsystem_1 [
shape=plain
label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="4">
<tr> <td> <b>Subsystem 1</b> </td> </tr>
<tr> <td>
<table border="0" cellborder="0" cellspacing="0" >
<tr> <td align="left">+ property</td> </tr>
<tr> <td align="left" port="r1">- resource</td> </tr>
<tr> <td align="left">...</td> </tr>
</table>
</td> </tr>
<tr> <td align="left">
+ method<br/>
...<br align="left"/>
</td> </tr>
</table>>
]
Subsystem_2 [
shape=plain
label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="4">
<tr> <td> <b>Subsystem 2</b> </td> </tr>
<tr> <td>
<table align="left" border="0" cellborder="0" cellspacing="0" >
<tr> <td align="left">+ property</td> </tr>
<tr> <td align="left" port="r1">- resource</td> </tr>
<tr> <td align="left">...</td> </tr>
</table>
</td> </tr>
<tr> <td align="left">
+ method<br/>
...<br align="left"/>
</td> </tr>
</table>>
]
Subsystem_3 [
shape=plain
label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="4">
<tr> <td> <b>Subsystem 3</b> </td> </tr>
<tr> <td>
<table border="0" cellborder="0" cellspacing="0" >
<tr> <td align="left">+ property</td> </tr>
<tr> <td align="left" port="r1">- resource</td> </tr>
<tr> <td align="left">...</td> </tr>
</table>
</td> </tr>
<tr> <td align="left">
+ method<br/>
...<br align="left"/>
</td> </tr>
</table>>
]
System_1:ss2 -> Subsystem_2;
System_1:ss3 -> Subsystem_3;
edge [xdir=back arrowtail=odiamond]
Subsystem_1:r1 -> "Shared resource" [label=aggregation]
Subsystem_2:r1 -> "Shared resource"
Subsystem_3:r1 -> "Shared resource"
"Shared resource" [
label = <{
<b>Shared resource</b>
|
+ property<br align="left"/>
...<br align="left"/>
|
+ method<br align="left"/>
...<br align="left"/>
}>
]
}
The HTML approach is however way too verbose for casually creating UML diagrams without extra tooling, as it requires too much formatting repetition.
A lightweight "poor man's approach" that still more clearly highlights node title than records could be to use subgraphs:
digraph {
node [shape=box]
subgraph cluster_house {
label="House"
hcw [label="Clean water"]
hdw [label="Dirty water"]
}
subgraph cluster_street {
label="Street"
scw [label="Clean water"]
sdw [label="Dirty water"]
}
scw -> hcw
hdw -> sdw
}
Docs: https://graphviz.org/docs/attrs/cluster/
Tested on Graphviz 2.42.2, Ubuntu 22.04.

Resources