Questions tagged [embedded-javascript]

Embedded JavaScript templates for node

Embedded Javascript is a template with JavaScript code embedded.

Anything inside the tag <%...%> is executed as JavaScript code, and anything inside the tag <%=...%> is replaced by the evaluated value.

Highlights :

HTML string concatenation without the messiness.

Easily load templates from separate files.

Rails-like view helpers.

Template caching and partials.

Intelligent error handling with line numbers.

References :

  1. Embedded JavaScript homepage

  2. Embedded JavaScript @GoogleCode

  3. Embedded JavaScript @GitHub

55 questions
2
votes
1 answer

EJS and Node, EJS throws an error if passed in object does not exist?

I am trying to pass a message object to a template using ejs. My route code is as follows: app.get('/', function(req, res) { res.render('index.ejs', {message: 'A message'}); }); In my ejs (index.ejs) file, I have: <% if (message) { %> …
Startec
  • 12,496
  • 23
  • 93
  • 160
1
vote
0 answers

How to load and use modules in embedded JavaScript (EJS) code

My current scripts/codes flow is index.js->routes.js->main.ejs I need to load a GeoTiff-related module and use its plotting functions in my main.ejs. However I find that ejs does not support loading modules within the code, so I need to load the…
1
vote
0 answers

How to create an embedded javascript form widget for an rails app?

In my Ruby on Rails app, bike rental companies can manage all their bikes (reservations, payments etc.). Context I would like to offer a bike rental companies (shops) the option to redirect guests to an online reservation process on my platform, so…
techquestion
  • 489
  • 5
  • 20
1
vote
1 answer

How to convert EJS Template's table column's strings in dd-mm-yyyy Formats?

I am rendering through EJS template like this and table data coming from Database <%= Patient.StudyDate %> Patient.StudyDate is a string and rendering as 20181029 (first 4 is a year then 2 is a month and last 2 is a day so I want to…
ArunPratap
  • 4,816
  • 7
  • 25
  • 43
1
vote
1 answer

Problem installing mjs library (embedded javascript) using platformio cli

I get a build error when trying to use a function in mjs after importing it into platformio: platformio lib --storage-dir lib install https://github.com/cesanta/mjs.git I can try #include <../lib/mjs/mjs.h>, but it will only include the header file…
TamusJRoyce
  • 817
  • 1
  • 12
  • 25
1
vote
1 answer

Use embedded js in ejs template to load static text file

I am currently working on a nodejs app using ejs view templates. I am trying to call upon large batches of text stored in a text file through embedded js in the template. Here is the code for the template currently …
Java Noob
  • 351
  • 1
  • 6
  • 15
1
vote
3 answers

Skip undefined values in if statement and loop

I'm trying to loop through all user's comments, but with an if statement looking for a certain value. Problem is my app breaks as some users havent made comments, and therefore i get a 'cannot read property of 'collected' undefined. How do I skip…
Adam Furniss
  • 37
  • 1
  • 6
1
vote
2 answers

How to compare a sessionStorage item value with a backend parameter in embedded javascript file?

I have a form which the user can fill and click a preview button (Preview will not save anything to database and will just create a view). I am implementing a "close preview" functionality which will take the user back to the filled form and give an…
A.R.K.S
  • 1,692
  • 5
  • 18
  • 40
1
vote
1 answer

Strange NodeJS with Express and EJS looping mystery

I have some JSON I'm passing to a partial view. { "0": { "storename": "Park plaza", "prediction": "Retail Sites", "probability": 0.851005 }, "1": { "storename": "Emory Mills", "prediction": "Retail Sites", "probability":…
Jeremy S
  • 11
  • 3
1
vote
1 answer

Embedded JavaScript (EJS) - Dynamically setting view from route

I'm learning nodejs at the moment and my .ejs template files are pretty much standard (header, footer, js-defaults etc) - and the only thing that changes it the content in a HTML div. I thought I could set a variable in my route and pass it along to…
ash
  • 1,224
  • 3
  • 26
  • 46
1
vote
1 answer

Is there a way to create a dynamic partial resulting from server treatment?

I've started to use NodeJS for a couple of months now and I came across a little problem with partials rendering. I'd like to include a partial view in some templates but I want this partial to be dynamically generated from the server (because it…
timothy.B
  • 116
  • 6
1
vote
1 answer

How to use jQuery and vanilla JS at EJS templates

I have a problem with executing jQuery code at EJS template. My code: $.json('/data.json', function (data) { new EJS({url: 'template.ejs'}).update('mycontainer', {data: data}); }) It works. But when I've tried to use some jQuery plugin at this…
Jim Moriarty
  • 133
  • 1
  • 4
1
vote
1 answer

sails.js: variables visible to ejs templates only when not testing for their existence

I'm new to the whole nodejs ecosystem so kindly speak slowly and use small words. In the past when developing a website with PHP I would typically have header.php and footer.php includes. The header include typically contains the HTML head element,…
jasper
  • 137
  • 1
  • 9
1
vote
2 answers

access controller object from a javascript file in sails js

I am new to sails js. I am passing a object from controller to view in sails js. I can access to that object from ejs (embedded javascript) file. But I need to access that object from a javascript file. Should I need to use the object in a hidden…
Gayan Charith
  • 7,301
  • 2
  • 20
  • 32
1
vote
1 answer

cannot access the row values of an object using javascript and ejs

I have an ejs file which looks like below Google Maps Sensor Markers
mo0206
  • 791
  • 5
  • 20
  • 36