carlsagan21 / ejs-simple-loader Goto Github PK
View Code? Open in Web Editor NEWbasic ejs loader for webpack
License: MIT License
basic ejs loader for webpack
License: MIT License
Hi , I am trying to pass object to .ejs through ejs-simple-loader
if object has two property , will get error
const testObj = { title: 'Fusion Net', name: 'Toby' };
but if object only have one property , will success
const testObj = { name: 'Toby' };
new HtmlWebpackPlugin({
template: 'ejs-simple-loader?data=' + ${JSON.stringify(testObj)} + '!./src/views/index.ejs',
}),
get variable from .ejs
<title> <%= JSON.parse(data).name %></title>
error log
ERROR in ./~/ejs-simple-loader?data={"title":"Fusion Net","name":"Toby"}!./src/views/index.ejs
Module build failed: TypeError: src/views/index.ejs:1
>> 1| <% include ./header.ejs %>
esc is not a function
at rethrow (/Users/luhua/Project/FusionNet/node_modules/ejs-simple-loader/node_modules/ejs/lib/ejs.js:285:18)
at eval (eval at compile (/Users/luhua/Project/FusionNet/node_modules/ejs-simple-loader/node_modules/ejs/lib/ejs.js:524:12), <anonymous>:20:9)
at eval (eval at compile (/Users/luhua/Project/FusionNet/node_modules/ejs-simple-loader/node_modules/ejs/lib/ejs.js:524:12), <anonymous>:22:10)
at returnedFn (/Users/luhua/Project/FusionNet/node_modules/ejs-simple-loader/node_modules/ejs/lib/ejs.js:555:17)
at Object.ejsSimpleLoader (/Users/luhua/Project/FusionNet/node_modules/ejs-simple-loader/index.js:32:47)
thanks for your helping
I'm getting the following output when trying to use this loader for my *.ejs file:
ERROR in ./main/frontend/index-dev.ejs (./node_modules/ejs-simple-loader!./main/frontend/index-dev.ejs)
Module build failed (from ./node_modules/ejs-simple-loader/index.js):
TypeError: Cannot read property 'ejsSimpleLoader' of undefined
The problem seems to be around these lines:
var configKey = loaderOptions.config || 'ejsSimpleLoader';
var globalOptions = this.options[configKey] || {};
If I change them to this, it works:
var configKey = loaderOptions.config || 'ejsSimpleLoader';
var globalOptions = this.options ? this.options[configKey] : {};
The problem is that this.options
comes in as undefined, and I'm not sure why. There's another project where I work that appears to be set up identically, but when it gets to this point, its this.options
is defined as:
{ output: { filename: 'index.html', publicPath: undefined } }
How does this library set this.options
and how can I fix this?
Hi,
How can I get the variable from ejs-simple-loader in .ejs file
it's my config
new HtmlWebpackPlugin({ filename: './views/index.html', template: 'ejs-simple-loader?title'+ 'toby' +'!./src/views/index.ejs', inject: 'body', hash: true, chunks: ['index'], alwaysWriteToDisk: true, })
Am i right?
<title><%= title %></title>
thanks for your help ๐ฏโโ๏ธ
webpack:2.3.3
Error:
ERROR in Error: Child compilation failed:
Module build failed: TypeError: Cannot read property 'config' of null
- TypeError: Cannot read property 'config' of null
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.