How to use the compile function from ejs
Find comprehensive JavaScript ejs.compile code examples handpicked from public code repositorys.
27 28 29 30 31 32 33 34 35 36
options: OptionsI ) { const path = join(__dirname, 'views', 'result.ejs'); const targetPath = join(process.cwd(), '/bba', 'bba'); const ejsString = ejs.fileLoader(path, 'utf8'), template = ejs.compile(ejsString, { bundleReport, options, filename: path, }),
0
5
2
GitHub: mde/ejs
48 49 50 51 52 53 54 55 56 57
Try EJS online at: https://ionicabizau.github.io/ejs-playground/. ## Basic usage ```javascript let template = ejs.compile(str, options); template(data); // => Rendered HTML string ejs.render(str, data, options);
781
0
121
+ 3 other calls in file
GitHub: ggeorgaras/ejs
33 34 35 36 37 38 39 40 41 42
``` ## Usage ```javascript var template = ejs.compile(str, options); template(data); // => Rendered HTML string ejs.render(str, data, options);
778
0
1
GitHub: opadfnezig/JS-BuyList
218 219 220 221 222 223 224 225 226 227
var ejs = require('ejs'); exports.PizzaMenu_OneItem = ejs.compile("<%\nfunction getIngredientsArray(pizza) {\n //Отримує вміст піци\n var content = pizza.content;\n var result = [];\n\n //Object.keys повертає масив ключів в об’єкті JavaScript\n\n Object.keys(content).forEach(function (key) {\n\n //a.concat(b) створює спільний масив із масивів a та b\n result = result.concat(content[key]);\n });\n\n return result;\n}\n%>\n<div class=\"col-sm-12 col-md-6 col-lg-4 p-3\">\n <div class=\"card pizza-card\">\n <img class=\"card-img-top\" src=\"<%= pizza.icon %>\" alt=\"Pizza\">\n <div class=\"card-body\">\n <div class=\"caption d-flex flex-column\">\n <% if(pizza.is_new) { %>\n <span class=\"new\">Нова</span>\n <% } else if(pizza.is_popular) { %>\n <span class=\"popular\">Популярна</span>\n <% } %>\n <h3><%= pizza.title %></h3>\n <div class=\"type\"><%= pizza.type %></div>\n <p>\n <%= getIngredientsArray(pizza).join(\", \") %>\n </p>\n\n <div class=\"price-container d-flex justify-content-around mt-auto\">\n <% if(pizza.small_size) { %>\n <div class=\"title-size\">\n <div>\n <img src=\"assets/images/size-icon.svg\">\n <%= pizza.small_size.size %>\n </div>\n <div>\n <img src=\"assets/images/weight.svg\">\n <%= pizza.small_size.weight %>\n </div>\n <h2><%= pizza.small_size.price %></h2>\n <h6>грн.</h6>\n <button class=\"btn btn-warning buy-small\">Купити</button>\n </div>\n <% } if(pizza.big_size) { %>\n <div class=\"title-size\">\n <div>\n <img src=\"assets/images/size-icon.svg\">\n <%= pizza.big_size.size %>\n </div>\n <div>\n <img src=\"assets/images/weight.svg\">\n <%= pizza.big_size.weight %>\n </div>\n <h2><%= pizza.big_size.price %></h2>\n <h6>грн.</h6>\n <button class=\"btn btn-warning buy-big\">Купити</button>\n </div>\n <% } %>\n </div>\n\n </div>\n </div>\n </div>\n</div>\n</div>"); exports.PizzaCart_OneItem = ejs.compile("<div class = \"pizza-order\">\n <div style = \"display: inline-block\">\n <div class = \"pizza-name\"><%= pizza.title %> (\n <%if(size === \"small_size\") {%>\n <%= \"Мала\"%>\n <%} else {%>\n <%= \"Велика\"%>\n <%}%>\n )</div>\n <div style = \"padding-left:5px\">\n <img style = \"width:8px\" src = \"assets/images/size-icon.svg\">\n 30\n <img style=\"width: 8px\" src = \"assets/images/weight.svg\">\n 480\n </div>\n <div style = \" padding-left:5px;padding-top: 10px\">\n <span class = \"pizza-price\"><%= pizza[size].price*quantity %> грн.</span>\n <button class = \"btn btn-danger minus\">-</button>\n <span style =\"padding: 3px 10px 0 10px\"><%= quantity %></span>\n <button class = \"btn btn-success plus\">+</button>\n <button class = \"btn btn-default delete\">x</button>\n </div>\n </div>\n <img class = \"pizza-icon\" src = <%= pizza.icon%>>\n</div>"); },{"ejs":8}],4:[function(require,module,exports){ /** * Created by chaika on 25.01.16.
187
0
0
+ 7 other calls in file
GitHub: kovaIenko/JS-Pizza
181 182 183 184 185 186 187 188 189 190
*/ var ejs = require('ejs'); exports.PizzaMenu_OneItem = ejs.compile("<%\r\n\r\nfunction getIngredientsArray(pizza) {\r\n //Отримує вміст піци\r\n var content = pizza.content;\r\n var result = [];\r\n\r\n //Object.keys повертає масив ключів в об’єкті JavaScript\r\n\r\n Object.keys(content).forEach(function(key){\r\n\r\n //a.concat(b) створює спільний масив із масивів a та b\r\n result = result.concat(content[key]);\r\n });\r\n\r\n return result;\r\n}\r\n %>\r\n<div class=\"col-xs-12 col-sm-6 col-md-4 pizza-card\">\r\n <div class=\"thumbnail\">\r\n\r\n <img class=\"pizza-icon\" src=\"<%= pizza.icon %>\" alt=\"Pizza\">\r\n <% if(pizza.is_new) { %>\r\n <span class=\"label label-danger\">Нова</span>\r\n <% } else if(pizza.is_popular) {%>\r\n <span class=\"label label-success\">Популярна</span>\r\n <% } %>\r\n\r\n <div class=\"caption\">\r\n <span class=\"title\"><%= pizza.title %></span>\r\n <div class=\"type\"><%= pizza.type %></div>\r\n <div class=\"description\">\r\n <%= getIngredientsArray(pizza).join(\", \") %>\r\n </div>\r\n\r\n\r\n <!-- Перед тим щоб показати кнопку необхідно переконатися, що піца має великий розмір -->\r\n <% if(pizza.small_size) { %>\r\n <div class=\"buy-small chose\">\r\n <span> <img src=\"assets/images/size-icon.svg\" class=\"\" ><%=pizza.small_size.size %></span>\r\n <span> <img src=\"assets/images/weight.svg\" class=\"\" ><%=pizza.small_size.weight %></span>\r\n <span class=\"price\"><%=pizza.small_size.price %></span>\r\n <span class=\"value\">грн</span>\r\n <button class=\"btn btn-default small_buy\">Купити</button>\r\n </div>\r\n <% } %>\r\n <% if(pizza.big_size) { %>\r\n <div class=\"buy-big chose\">\r\n <span> <img src=\"assets/images/size-icon.svg\" class=\"\" ><%=pizza.big_size.size %></span>\r\n <span > <img src=\"assets/images/weight.svg\" class=\"\" ><%=pizza.big_size.weight %></span>\r\n <span class=\"price\"><%=pizza.big_size.weight %></span>\r\n <span class=\"value\">грн</span>\r\n <button class=\"btn btn-primary \">Купити </button>\r\n </div>\r\n <% } %>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n"); exports.PizzaCart_OneItem = ejs.compile("<div>\r\n <div class=\"booked\">\r\n <span class=\"name_name\"><%= name %></span>\r\n <!-- <div class=\"size\">\r\n <img src=\"assets/images/size-icon.svg\" class=\"on\">\r\n <span><%= pizza[size].size %></span>\r\n <img src=\"assets/images/weight.svg\" class=\"tw\">\r\n <span><%=pizza[size].weight%> </span>\r\n </div> -->\r\n <img class=\"ph\" src=\"<%= pizza.icon %>\" alt=\"Pizza\" >\r\n <!-- <%= pizza.title %> (<%= size %>)\r\n <div class=\"price\">Ціна: <%= pizza[size].price %> грн.</div> -->\r\n <div class=\"plus_minus\">\r\n <button class=\"btn btn-warning minus\">-</button>\r\n <span class=\"label label-default\"><%= quantity %></span>\r\n <button class=\"btn btn-success plus\">+</button>\r\n <button class=\"btn btn-danger delete\"> X </button>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n"); },{"ejs":7}],3:[function(require,module,exports){
170
0
1
+ 3 other calls in file
GitHub: marjanka/JS-Pizza
181 182 183 184 185 186 187 188 189 190
*/ var ejs = require('ejs'); exports.PizzaMenu_OneItem = ejs.compile("<%\r\n\r\nfunction getIngredientsArray(pizza) {\r\n //Отримує вміст піци\r\n var content = pizza.content;\r\n var result = [];\r\n\r\n //Object.keys повертає масив ключів в об’єкті JavaScript\r\n\r\n Object.keys(content).forEach(function(key){\r\n\r\n //a.concat(b) створює спільний масив із масивів a та b\r\n result = result.concat(content[key]);\r\n });\r\n\r\n return result;\r\n}\r\n\r\n %>\r\n<div class=\"col-sm-6 col-md-4 pizza-card\">\r\n <div class=\"thumbnail\">\r\n <img class=\"pizza-icon\" src=\"<%= pizza.icon %>\" alt=\"Pizza\">\r\n\r\n <% if(pizza.is_new) { %>\r\n <h3 class=\"label-new\"><span class=\"label label-danger\">Нова</span></h3>\r\n <% } else if(pizza.is_popular) {%>\r\n <h3 class=\"label-popular\"><span class=\"label label-success\">Популярна</span></h3>\r\n <% } %>\r\n\r\n <div class=\"caption\">\r\n <h3><span class=\"title\"><%= pizza.title %></span></h3>\r\n <div class=\"type\"><%= pizza.type %></div>\r\n <div class=\"description\">\r\n <%= getIngredientsArray(pizza).join(\", \") %>\r\n </div>\r\n <div class=\"row\">\r\n <% if(pizza.small_size && pizza.big_size) { %>\r\n <div class=\"col-sm-6 small-pizza\" >\r\n <div class=\"properties\">\r\n <img src=\"assets/images/size-icon.svg\"> <span><%= pizza.small_size.size %></span>\r\n <br>\r\n <img src=\"assets/images/weight.svg\"> <span><%= pizza.small_size.weight %></span>\r\n </div>\r\n <div ><span class=\"prise\"><%= pizza.small_size.price %></span><span> грн.</span></div>\r\n <a href=\"#\" class=\"btn btn-warning buy-small\">Купити</a>\r\n </div>\r\n\r\n <div class=\"col-sm-6 big-pizza\" >\r\n <div class=\"properties\">\r\n <img src=\"assets/images/size-icon.svg\"> <span><%= pizza.big_size.size %></span>\r\n <br>\r\n <img src=\"assets/images/weight.svg\"> <span><%= pizza.big_size.weight %></span>\r\n </div>\r\n <div ><span class=\"prise\"><%= pizza.big_size.price %></span><span> грн.</span></div>\r\n <a href=\"#\" class=\"btn btn-warning buy-big\">Купити</a>\r\n </div>\r\n <% } else if(pizza.small_size){ %>\r\n <div class=\"onetype-pizza\" >\r\n <div class=\"properties\">\r\n <img src=\"assets/images/size-icon.svg\"> <span><%= pizza.small_size.size %></span>\r\n <br>\r\n <img src=\"assets/images/weight.svg\"> <span><%= pizza.small_size.weight %></span>\r\n </div>\r\n <div ><span class=\"prise\"><%= pizza.small_size.price %></span><span> грн.</span></div>\r\n <a href=\"#\" class=\"btn btn-warning buy-small\">Купити</a>\r\n </div>\r\n <% } else if(pizza.big_size){ %>\r\n <div class=\"onetype-pizza\" >\r\n <div class=\"properties\">\r\n <img src=\"assets/images/size-icon.svg\"> <span><%= pizza.big_size.size %></span>\r\n <br>\r\n <img src=\"assets/images/weight.svg\"> <span><%= pizza.big_size.weight %></span>\r\n </div>\r\n <div ><span class=\"prise\"><%= pizza.big_size.price %></span><span> грн.</span></div>\r\n <a href=\"#\" class=\"btn btn-warning buy-big\">Купити</a>\r\n </div>\r\n <% } %>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n\r\n"); exports.PizzaCart_OneItem = ejs.compile("<div class=\"one-order\">\r\n <img class=\"pizza-icon\" src=\"<%= pizza.icon %>\" alt=\"Pizza\">\r\n <p>\r\n <h4> <%= pizza.title %></h4>\r\n </p>\r\n <div class=\"properties\">\r\n <img src=\"assets/images/size-icon.svg\"> <span><%= pizza[size].size %></span>\r\n <br>\r\n <img src=\"assets/images/weight.svg\"> <span><%= pizza[size].weight %></span>\r\n </div>\r\n <div class=\"price-box\">\r\n <span class=\"buy-price\"><%= pizza[size].price %>грн</span>\r\n <button class=\"btn btn-xs btn-danger btn-circle minus\">\r\n <span class=\"glyphicon glyphicon-minus icon-white\">\r\n </span>\r\n </button>\r\n <span class=\"buy-price order-pizza-count\"><%= quantity %></span>\r\n <button class=\"btn btn-xs btn-success btn-circle plus \">\r\n <span class=\"glyphicon glyphicon-plus icon-white\">\r\n </span>\r\n </button>\r\n <button class=\"btn btn-xs btn-default btn-circle delete \">\r\n <span class=\"glyphicon glyphicon-remove icon-white\">\r\n </span>\r\n </button>\r\n </div>\r\n</div>\r\n\r\n\r\n"); },{"ejs":8}],3:[function(require,module,exports){
170
0
2
+ 3 other calls in file
GitHub: kovaIenko/JS-Pizza
218 219 220 221 222 223 224 225 226 227
var ejs = require('ejs'); exports.PizzaMenu_OneItem = ejs.compile("<%\n\nfunction getIngredientsArray(pizza) {\n //Отримує вміст піци\n var content = pizza.content;\n var result = [];\n\n //Object.keys повертає масив ключів в об’єкті JavaScript\n\n Object.keys(content).forEach(function(key){\n\n //a.concat(b) створює спільний масив із масивів a та b\n result = result.concat(content[key]);\n });\n\n return result;\n}\n %>\n<div class=\"col-xs-12 col-sm-6 col-md-4 pizza-card\">\n <div class=\"thumbnail\">\n\n <img class=\"pizza-icon\" src=\"<%= pizza.icon %>\" alt=\"Pizza\">\n <% if(pizza.is_new) { %>\n <span class=\"label label-danger\">Нова</span>\n <% } else if(pizza.is_popular) {%>\n <span class=\"label label-success\">Популярна</span>\n <% } %>\n\n <div class=\"caption\">\n <span class=\"title\"><%= pizza.title %></span>\n <div class=\"type\"><%= pizza.type %></div>\n <div class=\"description\">\n <%= getIngredientsArray(pizza).join(\", \") %>\n </div>\n\n\n <!-- Перед тим щоб показати кнопку необхідно переконатися, що піца має великий розмір -->\n <div class=\"all_pizzes\">\n <% if(pizza.small_size) { %>\n <div class=\"buy-small chose col-sm-6\">\n <span> <img src=\"assets/images/size-icon.svg\" class=\"\" ><%=pizza.small_size.size %></span>\n <span> <img src=\"assets/images/weight.svg\" class=\"\" ><%=pizza.small_size.weight %></span>\n <span class=\"price\"><%=pizza.small_size.price %></span>\n <span class=\"value\">грн</span>\n <button class=\"btn btn-default small_buy\">Купити</button>\n </div>\n <% } %>\n <% if(pizza.big_size) { %>\n <div class=\"buy-big chose col-sm-6\">\n <span> <img src=\"assets/images/size-icon.svg\" class=\"\" ><%=pizza.big_size.size %></span>\n <span > <img src=\"assets/images/weight.svg\" class=\"\" ><%=pizza.big_size.weight %></span>\n <span class=\"price\"><%=pizza.big_size.price %></span>\n <span class=\"value\">грн</span>\n <button class=\"btn btn-primary big_buy\">Купити </button>\n </div>\n <% } %>\n </div>\n </div>\n </div>\n</div>\n\n"); exports.PizzaCart_OneItem = ejs.compile("<div>\n <div class=\"booked\">\n <% if(size==\"small_size\"){%>\n <span class=\"name_name\"><%= pizza.title %> (Мала)</span>\n <% }else if(size==\"big_size\") {%>\n <span class=\"name_name\"><%= pizza.title %> (Велика)</span>\n <%}%>\n <div class=\"size\">\n <img src=\"assets/images/size-icon.svg\" class=\"on\">\n <span><%= pizza[size].size %></span>\n <img src=\"assets/images/weight.svg\" class=\"tw\">\n <span><%=pizza[size].weight%> </span>\n </div>\n <img class=\"ph\" src=\"<%= pizza.icon %>\" alt=\"Pizza\" >\n <div class=\"price_\">Ціна: <span><%= pizza[size].price*quantity %></span> грн.</div>\n <div class=\"plus_minus\">\n <button class=\"btn btn-warning minus\">-</button>\n <span class=\"label label-default\"><%= quantity %></span>\n <button class=\"btn btn-success plus\">+</button>\n <button class=\"btn btn-danger delete\"> X </button>\n </div>\n </div>\n</div>\n\n"); },{"ejs":10}],4:[function(require,module,exports){ /** * Created by chaika on 25.01.16.
170
0
1
+ 3 other calls in file
ejs.renderFile is the most popular function in ejs (196 examples)