Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of name 'express' in JSX template engine name #5211

Open
dqh-au opened this issue Jun 10, 2023 · 2 comments
Open

Use of name 'express' in JSX template engine name #5211

dqh-au opened this issue Jun 10, 2023 · 2 comments
Labels

Comments

@dqh-au
Copy link

dqh-au commented Jun 10, 2023

I'm soon to release a JSX based template engine for Express (powered by NakedJSX), and I've tentatively named it @nakedjsx/express-jsx. I have opened this issue to ask whether you are comfortable with this use of the name 'express'.

Of course, 'express-jsx' by itself wouldn't be appropriate as it would create confusion about who made it. But perhaps given that it would live under the @NakedJSX org, the name used in all practical contexts would be the combined '@nakedjsx/express-jsx' which I like because it makes two things clear:

  1. It's not an official Express project
  2. It's a thing made by @NakedJSX that probably adds JSX to Express.

What are your thoughts?

@dougwilson
Copy link
Contributor

Hi @dqh-au thank you for reaching out on this, it is appreciated.

So my understanding of what you are saying is that there would be a module named @nakedjsx/express, is that right? I don't see any issue with that, at least I have no issue with such a name :) . Additionally, if you are saying that within NakedJSX (and sorry, I am reading about it now to get more familiar) you are saying someone would say to "render with 'express'" and under the hood it used this other module for the template engine, I think that is also perfectly fine instead of saying "render with 'express-jsx'".

You certainly know NakedJSX better than I, but if you want to have things directly use the name "express" vs "express-jsx" in order to template with Express, I don't see any issue with it, personally.

And of course as you flesh it out, I'm sure there are some places we can even add Express/NakedJSX links or usage to our website expressjs.com as well, if you like :)

@dqh-au
Copy link
Author

dqh-au commented Jun 11, 2023

Hi @dougwilson, thank you, I really appreciate it! And links back once it's released would be fantastic.

It hadn't occurred to me that a module called @nakedjsx/express might be ok - that is indeed a nice succinct name.

And yes, there would be a module called '@nakedjsx/express', that starts NakedJSX in template engine mode and provides a template engine for express, used like this: (snippet taken from my current test project)

const { createExpressJsx } = require('@nakedjsx/express-jsx');

// ...

const options =
    {
        srcDir,
        output:
            {
                viewsDir,
                tmpDir,
                staticDir,
                staticUriPrefix
            }
    };
const expressJsx = createExpressJsx(options)

//
// Configure express to use @nakedjsx/express-jsx as template engine
//

app.engine('mjs', expressJsx.engine);
app.use(express.static(staticDir));
app.set('views', viewsDir);
app.set('view engine', 'mjs');

Usage sadly can't be quite as simple as other template engines, needs that little bit of setup above. Essentially NakedJSX watches a srcDir (containing NakedJSX pages) and generates dummy *.jsx HTML generating .mjs files in the views folder. Those trick express into seeing a routed request as a valid template engine path, allowing @nakedjsx/express-jsx to forward the request to the running NakedJSX instance which executes an in-memory function compiled from the matching NakedJSX page to generate the HTML.

Those files are imported (once) into NakedJSX and executed in response to requests to generate HTML and other content on demand.

EDIT: things move quickly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants