Is ejs front-end or back-end? - ejs

Newbie question: I'm learning the MEAN stack and is use EJS (embedded javascript) as the template engine. It's website says its a "cleans the HTML out of your JavaScript with client side templates" but it seems like to me that the <%= %> and <% %> are compiled on the backend and sent to the client afterwards. Am I not understanding something?

EJS work for both server side and client side.
Personally i use it with nodejs ( server side ), and for the client side my choice is http://mustache.github.io feel comfortable with it.

To answer my own question, EJS is a server-side language. Works kind of like JSP or PHP.

Related

Embed Marketo Web to PDF

A client has asked for our design team to embed a Marketo form into a Interactive PDF.
I've advised against it as:
I don't know it's possible ( They've claimed it is )
It's a bit pointless added forms to pdf's when they have a website and app both with forms...
So anyway, even being advised against it, they are detemined that want this form embedding in the PDF.
Does anyone have any ideas? The embed code ( Client sent me - Claims this is to work in PDF's )
<script src="//pages.name.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_00000"></form>
<script>MktoForms2.loadForm("//pages.name.com", "000-XMS-000", 00000);</script>
Any help would be appreciated
It's not possible... at least not embedded in a PDF. The JavaScript interpreter in Acrobat and other JavaScript-capable viewers do not use the HTML object model. It uses the JavaScript core and an object model specific to PDF. However, see my comment for another option.

encoding problems on site.master page (asp.net mvc2) on production server (2003 with IIS 6)

I have a site that uses the Hebrew language.
All the pages looks great, expect from the text that is generated in site.master.
This text comes a gibberish.
This is from master page:
<ul id="menu">
<li>
<%: Html.ActionLink("לקוחות", "List", "Customers")%></li>
same code from any other page shows hebrew chars.
The result is either gibberish, or encoded gibberish:
<div id="title">
<h1>
îòøëú ðéäåì ùéáåõ èëðàéí</h1>
</div>
<div id="menucontainer">
<ul id="menu">
<li>
ì÷åçåú</li>
tried to switch encoding in the browser but nothing gets me back to Hebrew.
This happens ONLY on production server, on my Dev machine (win7) it works fine.
The views inside the master pages shows OK also on production.
Any ideas ?
My advice would be: ditch the IIS 6 and use IIS Express, which you can install on most old OS's. It does introduce another technology into the question but this technology is newer, easy to use, maintain and script and more suitable for this new range of web development technologies like MVC, etc.
So, if you have an option to select what you use and can make decisions about it, definitely go for it.
Alternatively, you can play around with server regional settings and stuff like that but you might end up losing lots of hours to this.

GWT and templating engine

I want to design a website using GWT. This is my understanding of how GWT pages will be delivered to the client browser - When the user puts in the URL into her browser she receives all the static HTML + GWT javascript, and then the javascript queries the server for the dynamic page content and adds it to the DOM. eg - For a blog page the content of the blog is queried by the javascript. is my understanding correct?
If I know that the content will surely be a part of the page(add does not depend on user clicking an expand button etc.), Will it be more efficient if the blog content was a part of the HTML initially served? Something that could be done by using a templating engine like django.
Is there a way to make a templating mechanism in GWT?
Yes, putting your content into the HTML will reduce the number of round trips the client makes to your server. It also means that the blog content won't have to wait for your GWT javascript to load before it can be displayed.
GWT itself isn't useful for a template system, but most servers that run GWT servlets will also support JSP pages. GWT works fine with these pages, you just need to put the GWT script tag in as usual. You will no doubt be able to find a ready-made templating solution but rolling your own is not too hard.

Wicket JavaScript browser compatibility

I am new to Wicket, I have seen that it has Ajax related components.
When it generates JavaScript at the client side, is this JavaScript code cross-browser compatible?
Wicket Ajax's capabilities have been rated A (cross browser compatible) in this article. Although a bit outdated, it still remains true.
Don't forget that you can also integrate jQuery, Script.aculo.us or any of the other "big" JavaScript libraries with Wicket.

htmlencode TinyMce/textarea to sql MVC 2 .net 4

I am creating a simple ‘site news’ feature on an MVC 2 .net 4 web site. The site news articles are kept in a simple sql data base, actually I’m doing it with Entity Framework Code First and compact sql, consisting of colums articleID, articleDate articleSummary and articleDetail (model.ItemEntry in code below). The articleDetail is a textarea that I would like to edit with TinyMce or some other WYSIWYG editors if you have alternate editors to suggest or recommend please do so and why.
I’m looking for a way to have the text in the articleDetail enterd by TinyMce by way of the textarea, which may contain html as well as text, htmlencoded as it’s recorded into rows of the table. Seems to me that would be a likely configuration option, I haven’t found it. And that by htmlencoding the textarea would bypass all the difficulties I’ve encountered while attempting to save the TinyMce/textarea data to sql.
Although I will use this live it’s mainly a learning experience. And I’m a bit stubborn on wanting to learn how to do this. Otherwise I would just use the textarea and skip the WYSIWYG for this simple application.
While attempting to compose simple text using TinyyMce I’ve run into the problem of .net 4 and requestvalidation. It appears that I would have to relax my security by placing <httpRuntime requestValidationMode="2.0" /> in the web config and add [ValidateInput(false)] to my controllers create post action. I don’t want to relax the security that .net 4 is providing, kinda stuck now as to how to strip the html from the TinyMce/textarea.
At this point it occurred to me that what I really wanted to do was htmlencode the text as it could be valuable to have some html formatting in the articleDetail. Blog posts and other applications save information in sql that will somehow eventually be html, how do they do it?
In Summary (some of) my questions are
Are there any WYSIWYG editors that htmlencode their content? That way I could have htmlencoded html news articles stored in sql. I’ll then be attempting to htmldecode that for display when news articles are displayed.
alternately
How might I just simplify strip the html from the TinyMce/textarea before I save to sql?
Is relaxing to requestValidationMode="2.0" my only solution?
Research resources I’ve found helpful in this learning experience.
Ack! couldn't post 'em as this is my first post. Gee I thought I read the FAQ and was being a good Nerditquette kinda guy. Incidently I composed this in Live writer and it's posted here on my blog including the links I had researched and found helpful.
Some relevant pieces of source code.
Create.aspx
<script type="text/javascript">
tinyMCE.init({
mode: "textareas",
theme: "simple"
});
<div class="editor-label">
<%: Html.LabelFor(model => model.ItemEntry) %>
</div>
<div class="editor-field">
<%: Html.TextAreaFor(model => model.ItemEntry) %>
<%: Html.ValidationMessageFor(model => model.ItemEntry) %>
</div>
NewsController.cs
// POST: /News/Create
[HttpPost]
// [ValidateInput(false)]
public ActionResult Create(Item item)
{
if (ModelState.IsValid)
{
siteNews.Items.Add(item);
siteNews.SaveChanges();
return RedirectToAction("Index");
}
return View(item);
}
Why would you want to htmlEncode your content just to save it in the database? It's a useless step.
Why do you want to strip the html if you're using a rich text editor? If just want text, stay with a textarea. You can configure tinyMCE to use bbtags but I would only use that for users who can't be trusted.
Setting your requestValidationMode to 2.0 is how you can allow your code to save html. There is nothing wrong with that.