In Sendgrid Design template, how to use handlebar iteration for table? - handlebars.js

I'm using SendGrid online "Design" template, with a module "code".
In their documentation (https://sendgrid.com/docs/ui/sending-email/editor/#code-modules), they say that de code editor does not modify or validate any HTML.
If I write this piece of code inside the code module:
<ul>
{{#each items}}
<li>test</li>
{{/each}}
</ul>
<table>
<tbody>
{{#each items}}
<tr>
<td>Col 1</td>
<td>Col 2</td>
</tr>
{{/each}}
</tbody>
</table>
it results in:
<ul>
{{#each items}}
<li>test</li>
{{/each}}
</ul>
{{#each items}}{{/each}}
<table>
<tbody><tr>
<td>Col 1</td>
<td>Col 2</td>
</tr></tbody>
</table>
We can see that the {{each}} function stays in the right place for the ul, but is remove from inside of the table. Is this a temporary bug? How can I do this simple operation?
Thanks for your help

I found a undocumented way to make this works. You will need to comment out the each helper like this:
<table>
<tbody>
<!-- {{#each items}} -->
<tr>
<td>Col 1</td>
<td>Col 2</td>
</tr>
<!-- {{/each}} -->
</tbody>
</table>

I get the same issue. Definitely a bug in the Design Editor. My work around was to:
Style the email with the Design Editor.
Export HTML.
Go back and create a new version of the transaction email using the 'Code Editor' and not the 'Design Editor'.
Paste in the previously exported HTML.
Find the table that needs the {{each}} loop and place the functions exactly as you did.

Related

HTML to Excel changes the code

In asp.net (vb), I am trying to write the HTML output that I can have a user open up a report in Excel. It's writing my file fine, but when Excel opens the file it is changing the HTML code. The part that it really changes are formulas!
For instance, I am writing out the following (part of the file):
<table>
<tr>
<td>Trial</td><td x:num x:fmla="=SUM(A2:A10)">0</td>
</tr>
</tr></table>
If I open the file in Excel, the cell has a formula of SUM(A13:A21).
Is there something I can do to prevent Excel from changing this when it opens? I want it to have exactly what I write, but it is changing A LOT!
Thanks for any ideas.
This gives me the expected outcome:
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<table>
<tr>
<td>Trial</td><td x:num x:fmla="=SUM($A$2:$A$10)">0</td>
</tr>
</tr>
</table>
</html>
Even without the $ the formula remains as-written: no adjustment.
Excel 2013/Win7
Tim headed me in the right direction, so thanks.
I'm posting what I found was my idiotic error, just to answer the question. No one is going to do what I did, but here it is.
I was doing a "table" tag for everything when I wrote my program, so my HTML looked like this:
<table><tr>
<tr>
<td x:num>11</td>
<td x:num>12</td>
<td x:num>13</td>
<td x:num>14</td>
</tr></table>
<table> <tr>
<td x:num>21</td>
<td x:num>22</td>
<td x:num>23</td>
<td x:num>24</td>
</tr></table>
<table> <tr>
<td x:num>31</td>
<td x:num>32</td>
<td x:num>33</td>
<td x:num>34</td>
</tr></table>
<tr>
<td>Total Weight</td>
<td></td>
<td x:num x:fmla="=SUM(D4:D10)">0</td>
</tr>
</table>
Obviously, that was changing everything. Changed it to one "table" at the top and "/table" at the end to fix it all.
Thanks for the help!
Ed

Bootstrap danger class not working for a table row

I have the following table in my Rails app:
<table class='table table-bordered table-hover table-striped'>
<thead>
<tr>
<th>ID</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr class='danger'>
<td><%= order.id %></td>
<td><%= order.status.name %></td>
</tr>
</tbody>
</table>
And the row with class 'danger' doesn't change the color. However, if I use the class 'success' it changes correctly.
I am using the twitter-bootstrap-rails gem.
twitter-bootstrap gem is currently using bootstrap v 2.3.2.
And as per the Bootstrap version 2.3.2 Documentation For Tables following are the available row classes:
Optional row classes
Use contextual classes to color table rows.
.success Indicates a successful or positive action.
.error Indicates a dangerous or potentially negative action.
.warning Indicates a warning that might need attention.
.info Used as an alternative to the default styles.
Which is why .success worked but NOT .danger.
I suppose you are looking for .error class.
it seems to be a know bug with tables.
Looks like this is a know bug in v3.0.3 and will be fixed in v3.1.0
refer this bug error page and this stack question
go through the https://getbootstrap.com/docs/4.3/content/tables/#contextual-classes here they specified all row and cell classes, you should modify your
<table class='table table-bordered table-hover table-striped'>
<thead>
<tr>
<th>ID</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr class='table-danger'>//Modified line
<td><%= order.id %></td>
<td><%= order.status.name %></td>
</tr>
</tbody>
Maybe you're using an old version for the Bootstrap gem, by the way the default gem has not been updated to the version 3 of Bootstrap, try using this resource
https://github.com/jasontorres/bootstrap-on-rails
As #Kirti said the correct class for the Bootstrap 2 version must be .error instead of .danger watch the official documentation:
http://getbootstrap.com/2.3.2/base-css.html#tables

Bootstrap table tbody scroll

I'm trying to customize my bootstrap table. If the table height is larger than a certain height I want the <tbody> to scroll without scrolling the rest of the table. I have tried pretty much everything I can think of but the table wont even change sizes.
Does anyone know what classes I need to modify to fix this? Here's the elements I use in my table:
<div class="table-responsive">
<table class="table table-condensed">
<colgroup>
<col class="col-xs-1"/>
<col class="col-xs-1"/>
</colgroup>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
And here's a jsFiddle.
I ran into a similar problem with Bootstrap 2.3.2. I had to modify my table some, but a pretty good website I found with a complete css solution is here:
http://www.cssbakery.com/2010/12/css-scrolling-tables-with-fixed.html
I basically took the scrollableArea and scrollableContainer css parts on this site, changed a couple class names to match with what I already had, and used this instead of bootstrap. Maybe this can help, maybe not, but definitely a good alternative.

Rails 4 adding Bootstrap

I have created a Rails 4 sample app. I added the twitter-bootstrap-rails gem and used the installer to set up all the files: rails generate bootstrap:install less. I then created a scaffold and migrated the database and the bootstrap.css showed up like it should of. I then created a model/view/controller by hand with no scaffolding and the bootstrap css is not being used on it. Here is my view:
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tr>
<td>Jason</td>
<td>John</td>
</tr>
<tbody>
</tbody>
</table>
I should have a striped table, but it is not working. Any ideas? Thanks.
IS it a copy paste error or is it your code?
notice that the row is not in the tbody and you only have one row put more then one to see if it is striped
Check in browser if your bootstrap classes are coming you can do this by searching for any bootstrap class in complied css . if it is not there check in application css file in assets folder if bootstrap is included or not ...
also correct your markup ...
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Jason</td>
<td>John</td>
</tr>
</tbody>
</table>

How can I style normal html tables (or ASP tables) like the rest of the RadGrid in my website?

I'd like to have a normal table to look like RadGrids, is there an easy way I can use the RadGrid styles (keeping theming in mind)?
Using a tool like Firebug, you can inspect the table generated by RadGrid.
The example shown on this page gives the following results:
<table class="rgMasterTable rgClipCells">
<thead>
<th class="rgHeader" scope="col">header</th>
</thead>
<tbody>
<td class="rgRow">cell</td>
</tbody>
</table>
Adding the classes stated here to your own table should copy the style from the rad grid.
I have been playing with this, and it seems you need to wrap the table in div(s) with certain styles - maybe due to themes? Maybe I'm still missing something, but this is the only way I could get it to work.
<div class="RadGrid RadGrid_Sunset">
<table class="rgMasterTable rgClipCells">
<thead>
<th class="rgHeader" scope="col">header</th>
</thead>
<tbody>
<td class="rgRow">cell</td>
</tbody>
</table>
</div>

Resources