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
9
votes
1 answer

Creating an embeddable javascript widget

I'm trying to figure out the best way to create a javascript widget that: - Can be embedded in most websites - It's self contained (initially only - Can be configured An example of desired functionality would be Stripe's checkout widget: link I'm…
jasalguero
  • 4,142
  • 2
  • 31
  • 52
9
votes
1 answer

how to format a date in embeddedjs

app.js app.get('/user.html', function(req, res){ dbConnect.collection("users").find().toArray(function(err, docsData) { res.render('user', { data: docsData, title: "EJS example", header: "Some users" …
Naveen
  • 757
  • 3
  • 17
  • 41
8
votes
2 answers

Multiple variables declaration in ejs

I am trying to declare and assign a default value to multiple variables. But the value is only getting assigned to last variable <% var scale_text,scale_image = 'free_transform'; %> This print empty: <%- scale_text %> This prints…
Khawer Zeshan
  • 9,470
  • 6
  • 40
  • 63
8
votes
1 answer

Sublime Text 3 Package for EJS formatting

I'm looking for a package to format my ejs files. I already found "html-css-js prettify" and set "ejs" as an allowed_file_extensions but this didn't work. When I use de default configuration in the other options all expression language broke. When I…
7
votes
1 answer

Nodejs - How to show qr-image result in view

I use qr-image plugin for Nodejs to generate a QR code and it works pretty good. The problem is showing result image in ejs. var express = require('express'); var router = express.Router(); var qr = require('qr-image'); router.get('/',…
Morteza
  • 2,097
  • 5
  • 28
  • 47
6
votes
2 answers

Is it possible to minify JS code inside ejs files?

I'm wondering if it is possible to minify the JS code contained inside template files like EJS files. Is it useful? I'm thinking about performances. It's still a way to hide comments, explanations.
Vadorequest
  • 16,593
  • 24
  • 118
  • 215
5
votes
1 answer

How to include a JS script in a ejs file, nodeJS app?

I'm doing the nodeJS tuto on openclassroom. I use the template engine ejs. I try to run a simple JS script but I can't. Here is my app structure: App_toDoList/ │ ├──app.js ├──package-lock.json ├──package.json │ ├── js/ ├── node_modules/ └── views/ …
Théo.B
  • 99
  • 1
  • 1
  • 7
5
votes
1 answer

Express + Node.js Can't get Image to load

Very new to MEAN Stack and I'm using Brackets to edit .ejs views for a simple form app using Express tutorial. I'm trying load a static image and it just won't load. I'm getting GET /public/ggcbear.jpg 404 from app.js (terminal). I also created a…
4
votes
4 answers

Is there a way to keep the file extension of ejs file as .html?

I am developing an expressjs app using ejs templating engine. But i want to use keep the extension of ejs file like home.html instead of using home.ejs. The reason for this i am using visual studio for development and visual studio doesn't support…
manas
  • 6,119
  • 10
  • 45
  • 56
4
votes
1 answer

Formatting ejs template files in emacs

Is there any emacs mode that can format properly the ejs template file. Sample EJS template file <%= doc.session_name %>
    <% var p = {}; %> <% var…
Talespin_Kit
  • 20,830
  • 29
  • 89
  • 135
4
votes
2 answers

How should I use ejs to render table vertically?

I have an array like the following: quotation: [{ "dimension" : 0, "currency": "RMB", "quantity": "100", "price": "3", "factory": "rx"}, { "dimension" :…
Cheung Brian
  • 715
  • 4
  • 11
  • 29
3
votes
1 answer

Accessing object value in array from json in node route

How can access an object value in an array? Specifically "namecase" value? I have a ejs view looping in the array so that it can display all my object values. I'm passing data through routes. //data.json { "works": [{ "company" : "Company…
rrudy90023
  • 63
  • 2
  • 8
2
votes
1 answer

How much of load can LokiJs handle

I am planning to use lokijs with a node server. I am not sure how much of the load can it handle in coparison with mongodb? I would like to know how smooth can it run with 100000 documents in it? Thanks Vasanth
vasanth.v
  • 235
  • 3
  • 14
2
votes
1 answer

Empty parameters sent to EJS on render

Im fairly new to nodejs, and Ive been suffering trying to solve this, and so far I cant find the problem. At some point during my application I render a EJS template with some parameters, but it seems that even though the parameters are obtained,…
cavpollo
  • 4,071
  • 2
  • 40
  • 64
2
votes
3 answers

node ejs reference error data not defined at eval when handing data to view

i've been closing in on a node application using express and ejs, but when i try to hand data to my view from the controller like so var myData = { theData: data }; res.render(path.join(__dirname + '/../views/index'), myData); i get a nice error…
user4321260
1
2 3 4