1

Is it posible to add files that dont have the .ejs ending when using the ejs template engine with node.js and express?

I want to put shaders in seperate files with .glsl ending for example. Than I want to include them like this:

<% include /shaders/example.vertex.glsl %>

If I use example.vertex.glsl.ejs it works, but than syntax highlighting for shaders is not working anymore...

I am actually not bound to ejs. Any other express templating engine this would work in is fine. I just used ejs because I worked with it already a little bit beforehand.

asked Oct 9, 2016 at 6:41

1 Answer 1

1

You can do this as long as you tell the express what engine should be used to process the extension with app.engine(ext, callback).

Set the following before your routes somewhere:

app.engine('glsl', require('ejs').renderFile);

Then your includes such as <% include /shaders/example.vertex.glsl %> will work fine. These are processed in the same way as ejs files then, so as well as the include working as you describe, you can also put inline <%=variableFromNode%> type stuff in the included glsl files and it will process that too.

answered Nov 4, 2016 at 15:27
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.