How to use EJS (Embedded JavaScript templates) in NetSuite with SuiteScript 2.0 - ejs

I want to use EJS in my SuiteScript with the 2.0 APIs. I wonder if EJS is supported by NetSuite by default (like jQuery) or I have to go some extra steps to do so.
Particularly, I hope to use var page = new EJS({url: urlString}).render(dataOptions)
Thanks!

You can use any AMD-compatible library in SuiteScript by uploading the source file to the File Cabinet and including it as a dependency in your script module. As long as EJS provides an AMD-compatible format, you should have no problem adding it to a script.
Remember that all server-side SuiteScript runs on Rhino which only supports ECMA 5.1, so if the library contains a bunch of ES6+ stuff, it will only work client-side, and will likely error out server-side.

Related

Shopware: Injection of JS library on FE

I'm new to shopware and currently learning plugin development. I'm creating a plugin that needs to load a JavaScript library to be loaded only in PDP and it needs API credentials from the database.
The docs cover how to load JavaScript via JavaScript plugins but I need to fetch data from the BE, are there any docs covering this topic or how do I start implementing this feature?
To make (mostly static) data - like a API configuration - from the database available in the Frontend Javascript code, you can print out that data in the Twig template. The Shopware core assigns such data to the window object. You can do the same in your plugin.
To do this, you also have to "transport" the data first to the the Twig file, like described in another doc page.

JST Template Engine with Slim & Coffeescript

This wiki page explains how to create a directory of Javascript templates that can be accessed from a JST object in the DOM:
https://github.com/marionettejs/backbone.marionette/wiki/Using-jst-templates-with-marionette
JST stands for Javascript Templates. This feature — available by default in Rails 3.1 (see notes)— allows you to distribute your Javascript templates as ready-to-use functions in your scripts.
This mechanism is very useful because it avoids having to download templates asynchronously or to distribute them in the source code of your pages.
(Please refer to the post for further info)
The example template engines given include pairing simple HTML with embedded Javascript and Coffeescript, and HAML files with embedded Coffeescript.
I am wondering if there is a similar template engine available that uses Slim and Coffeescript, that would allow me to achieve the same result.
For those interested, I have found an engine that does what I was looking for: https://github.com/jfirebaugh/skim
It's specifically for rails projects (for the time being), but enables the creation of Javascript Templates using Slim.
It's similar to haml_coffee (https://github.com/netzpirat/haml_coffee_assets), just uses slim instead of haml

Scala - Template based run time code generation

I am looking for a good template based run-time code generation library in Scala. I need this for my ERP system to generate artifacts (html, and other code files)
Can any please point me in right direction?
You should take a look at Scalate. It has multiple syntax choices and if you use SSP you can easily create templates for text other than HTML as well.
If your app is web-based, Play has a templating system for generating the output pages.

How to use History.js with GWT?

I want to use History.js from Google Web Toolkit.
I know GWT has History functionality of it's own, but I don't like it because it uses the hashes in the URI, I want to use the new HTML5 History API as much as possible.
The only current way that I can think of to run History.js and GWT together is to write the History.js part in plain Javascript (or jQuery) and then manually call a GWT method.
It would be nice if it was possible to use the whole History.js functionality from within GWT's Java files.
No pain at all with that .
You just simple add your History js file on your document and you can use it .
Here i answered how you can use an external js in GWT .
Using externel js in GWT
After you call the native method you can continue with gwt method

Translate Zend Framework website like WPML in Wordpress

I want to know if it's possible to translate a Zend Framework 1 website in a manner similar with the one implemented by WPML for Wordpress.
What I want is to make an application that can scan the website source code for translation variables, then store them in a database or a .po file.
Also please note that I am not interested in switching to another framework or using only Wordpress for my website but in a method of simple and easy translation for someone without programming skills.
What you need is:
Zend_Translate with gettext adapter
Zend_Registry
Poedit
More info here.
PoEdit http://www.poedit.net/download.php
I have used this software to create .mo files for Zend_Translate gettext adapter in one of my ZF projects.