marko

Is there a way to use Marko without the require hook extension?


All of the markojs.com documentation says to render your marko templates like so:

require('marko/node-require')
require('./template.marko').render()

However, I couldn't find any ability to render marko templates that don't make use of a require hook.

I was hoping for something like this:

require('marko').compile('./template.marko').render()
// or the shorthand
require('marko').render('./template.marko')

What are my options here?


Solution

  • Just going to copy over my response from the Marko Gitter for greater visibility.

    Your best options here are either:

    1. Use require('marko').load(filename)
    2. Pre compile your server side templates using webpack, rollup or parcel.