Comments (3)
Thank you! I upgraded to 2.2.0 and it also allows include paths to be relative to the template. Had some problems in mocha when they were relative to where webpack was run.
from ejs-compiled-loader.
An example for if ... else and a ternary expression would be appreciated. Having trouble to get any of them to work.
<% if(optional) {
include partial
} %>
partial.ejs:
<h2><%= optional %></h2>
Results in this:
Module build failed: SyntaxError: Unexpected identifier in "."
at Object.exports.compile (C:\git\misc\designsystem\node_modules\ejs-compiled-loader\node_modules\ejs\lib\ejs.js:258:14)
at Object.module.exports (C:\git\misc\designsystem\node_modules\ejs-compiled-loader\index.js:7:22)
It doesn't matter if supply the parameter optional
or not, it still fails.
Just this:
<% include partial %>
And passing the parameter optional
works.
If not passing optional
, it compiles and I get an error in the console, which I expected to see.
optional is not defined
from ejs-compiled-loader.
<% if(optional) {
include partial
} %>
should look like
<% if(optional) { %>
<%- include partial %>
<% } %>
If you're using the version installed by default from npm, the correct docs are here. You can install the actual latest version, which uses this version of ejs with npm install ejs-compiled-loader@^2.2.0
or yarn add ejs-compiled-loader@^2.2.0
It's pretty confusing at the moment, took me a while to figure out.
Edit: Sorry, I forgot to answer the original question. I don't know if there's any way to keep it from spitting out an error when ejs tries to resolve optional
. You might want to do something like
<% var optional = optional || false; %>
<% if(optional) { %>
<%- include partial %>
<% } %>
from ejs-compiled-loader.
Related Issues (20)
- Partials not found HOT 9
- "compileDebug" option causing utils is not defined" HOT 1
- In search of collaborator HOT 8
- How to set ‘open’ and 'close' HOT 1
- Replace loaderUtils.parseQuery() with loaderUtils.getOptions() HOT 3
- why using git to download the ejs dependency? HOT 1
- Recompile child partial not working HOT 2
- ENOENT: no such file or directory when passing local data using include HOT 3
- could not support weapack4 HOT 5
- does not use npm package for ejs. uses git contributer. HOT 1
- Please update ejs to the latest version
- Readme install directs to other resources
- Drop-In-Replacement for this HOT 6
- npm audit warnings HOT 3
- A valid query string passed to parseQuery should begin with '?' HOT 10
- Upgrade to ejs ^3.0 or dynamic includes HOT 2
- > I also had this issue, but It can't be solved by the above method, So someone can help me, thank you.
- Depends on vulnerable versions of merge HOT 1
- Critical security vulnerability
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ejs-compiled-loader.