Giter Site home page Giter Site logo

parcel-plugin-ejs's People

Contributors

vabruzzo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

parcel-plugin-ejs's Issues

how to use .ejsrc.js or .ejs.config.js ?

Hello,
I'm trying to build an app with your transformer.

It works great if I put my local vars in .ejsrc (like in the readme)

But I'd like to set some local vars in javascript, because some of their values need to be computed, not hardcoded.

So I created an .ejsrc.js and tried to define a global object "locals" inside, but it doesn't work.

No luck with ejs.config.js either.

Ex: .ejsrc contains:

foo = 1;

locals = {
  bar: 2
}

if my index.ejs contains:

  • <%= foo %> => 1 (OK)
  • <%= locals.bar %> => undefined (should be 2)
  • <%= locals %> => empty object (should be {bar: 2} )

What's the good way to set local vars in JS please?

Thanks a lot

Docs?

Is there any documentation on how to use this with parcel? I installed it but my ejs files are not compiling blank.

ParcelJS doesn't parse .ejs files?

Hello,

I just installed as requested the plugin by executing the command:

npm i -S parcel-plugin-ejs

Unfortunately my index.html file is empty.
Here's my script to start ParcelJS:

cross-env NODE_ENV=development parcel ./src/index.ejs

It would be more useful to import the compiled template than the generated text

ejs templates are meant to be used with different render data, and when importing them, there is no way to pass render data.
I think it will be more useful to import the compiled template instead.

How it works currently

<button><% buttonText %></button>
import rendered from './template.ejs';

results in error: buttonText is not defined

The Suggestion

With the same ejs file,

import template from './template.ejs';
const rendered = template({
    buttonText: 'Click Me'
});

This change would be a matter of changing this line from return compiled(); to return compiled;.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.