Sendgrid v3 template replace string - node.js

I am trying to replace the strings in my template
To do this ive done the following:
section = helper.Section("%course_name%", "Tekst");
mail.addSection(section);
section = helper.Section("%user%", "Textforasubstitutiontagofsection2");
mail.addSection(section);
However when i recieve the mail the strings are not replace and stand as the above picture
Can anyone tell me what im doing wrong?

You want to be using substitutions rather than sections in this case. section tags are meant to encapsulate groups of substitution tags. Docs for more info.

Related

NetSuite Advanced PDF - How to set <#ftl output_format = "HTML" />

I've built many many many Advanced PDFs in the past couple of years. There is one thing that always sticks...
This applies mainly to SuiteScript rendered PDF templates.
The PDFs error if the user fields include & or -- or any other unesdcaped string literal. The default output_format is undefined
I'm looking at FTL documentation and can set <#ftl output_format = "HTML" /> but no matter where I put this in the PDF template, it fails.
Is there a particular place I need to declare this in the template?
It's not feasible to globally replace "&" with "&" everywhere etc...
Not sure that this answers the exact question you're asking, but I don't think it's the output format that's your problem here. My understanding is that the output format refers to what's generated by the template - ie: the final render. The output format, in any case, should be XML, as that's what's consumed by the BFO tag library when you're creating PDFs.
I think the issue is that your XML itself is not valid when string literals contain XML control characters of "&", "<" or ">". To avoid this, when building your templates and adding strings with SuiteScript, you can use the N/xml module's xml.escape() method to wrap anything that could contain one of those characters.
Sorry if I'm off base with this, but hope it helps.

NodeJS Jade (Pug) inline link in dynamic text

I have this NodeJS application, that uses Jade as template language. On one particular page, one text block is retrieved from the server, which reads the text from database.
The problem is, the returned text might contain line-breaks and links, and an operator might change this text at any time. How do I make these elements display correctly?
Most answers suggest using a new line:
p
| this is the start of the para
a(href='http://example.com') a link
| and this is the rest of the paragraph
But I cannot do this, since I cannot know when the a element appears. I've solved how to get newline correct, by this trick:
p
each l in line.description.split(/\n/)
= l
br
But I cannot seem to solve how to get links to render correctly. Does anyone know?
Edit:
I am open to any kind of format for links in the database, whatever would solve the issue. For example, say database contains the following text:
Hello!
We would like you to visit [a("http://www.google.com")Google]
Then we would like that to output text that looks like this:
Hello!
We would like you to visit Google
Looks like what you're looking for is unescaped string interpolation. The link does not work in the output because Pug automatically escapes it. Wrap the content you want to insert with !{} and it should stop breaking links. (Disclaimer: Make sure you don't leave user input unescaped - this only is a viable option if you know for sure the content of your DB does not have unwanted HTML/JS code in it.)
See this CodePen for illustration.
With this approach, you would need to use standard HTML tags (<a>) in your DB text. If you don't want that, you could have a look at Pug filters such as markdown-it (you will still need to un-escape the compilation output of that filter).

how to modify _xspAppSearchSubmit on Application Layout Xpages

Im trying to modify search parameter in Application Layout Search, to accept dot(.) as literal part of search item for filtering a view..
for example...
"Mr. Smith" will not show up in the view, but
"Mr.Smith" will..
digging deeper with google debugger, I found the function _xspAppSearchSubmit where I can simply change the code encodeURIComponent(val) into encodeURIComponent(val.replace(/s+\.s+/g,'')
which worked when i tested on console. The s+ to remove spaces, \. to keep the dot as literal.
BUT somehow, I cannot find this function in the ApplicationLayout1 custom control, and listed only one event - onItemClick.
Is it possible to add an "onChange" event?
There's an option and optionParam property there but not sure how to apply this.
Im a newbie with xpage and this control, can someone help me work around this, I've checked other sites about this but doesn't explain this kind of issue. I've also checked encodeURIComponent functionality, but it still interprets dot as command. I also learned this dot works like * wildcard.
the Application Layout is ccBaseUI from "One UI", and setup Basic Application Configuration.
code snippet capture

Custom query string in domino URL

Need a way to pass a value between to pages using URL query strings if possible. However everytime I add "?customquery=customvalue" at the end it ends up to the 404 page of the website.
I want to basically make it look like this.
https://example.com/somedepartment/sample.nsf/page/hello+world?customquery=customvalue
hello+world is a document that is equivalent to a webpage.
I tried this plus a javascript that collects the strings after the number sign and it works.
https://example.com/somedepartment/sample.nsf/page/hello+world#customvalue
However, I couldn't use the hash sign because they told me not to use it and use another unique symbol instead. I am not aware of any symbols that could work the same with hash sign. If there is, please enlighten me.
Apparently, I was able to find an answer.
https://example.com/somedepartment/sample.nsf/page/hello+world?OpenDocument&RandomParam=sample
Now I could pass values by means of this format. Basically it has to be preceded by "OpenDocument" parameter before putting custom ones.
This documentation also helps: http://www.ibm.com/developerworks/lotus/library/ls-Domino_URL_cheat_sheet/

New line in node.js mailer template

I'm using node.js mailer module to send email from node server. I used template file for that but I got all spaces trimmed when the message was sent. I tried to add '\n' at the end line of the template but it doesn't work also. Here is an example of template file:
Hi {{username}},\\n
Thanks for creating an account with us
I tried \n and \n , nothing all doesn't work. Any help?
Thanks,
nodemailer supports two types of templates, i.e. text and html (or templateFn() - case of loopback).
The option text is used for email clients which don't support HTML rendering so that \n should be used in this option for a new line.
On the contrary, you should swap \n with <br> in the option html.
Hope this would help you.
It's a known behavior, mustache is made to work with HTML templates, in HTML, new lines will be contracted as one space only.
You can try doing something like {{new_line}} instead your \\n, and define new_line: "\n\xA0" in your datas. \xA0 is the non-breakable space, it can separate line if you want to make two new lines.
An other solution is to not use the template, but just get the content of the file as text with fs.readFileSync(filename) and use a regexp to replace {{xxx}} by an object content.

Resources