iris.Jet: no view engine found for '.jet' or '.html'

Created on 5 Aug 2019  路  4Comments  路  Source: kataras/iris

Hi @kataras,

I use the new ViewEngine for Jet, but there is a problem:

no view engine found for '.html'

I use:

tmpl := iris.Jet("./views", ".jet.html") // no view engine found for '.html'
// ....
ctx.View("pages/index.jet.html", todos)

// or

tmpl := iris.Jet("./views", ".html.jet") // no view engine found for '.jet'
// ....
ctx.View("pages/index.html.jet", todos)

In view of this the Problem is here:
https://github.com/kataras/iris/blob/eba6adbd78bb547b220f7fe7fbda331532134e87/view/view.go#L23-L28
Because it only takes over the last point of the expansion, but in Jet it can also be .jet, .jet.html and .html.jet, which do not match here.

Either it has to be adapted there, the jet engine should be adapted.

What are you thinking?

Regards, Josef

resolved bug

All 4 comments

Hello Josef,

I see, the problem is on filepath.Ext. You shouldn't register the jet view engine twice, an improvement will be to accept more than one extension for the same view engine (the general code you pointed out is correct as it is. It does not allow the same extension to be used in more than view engine. Unique extension(s) per view engine, two view engines can't share the same extension as the context.View uses the extension and calls the Find method to select what view engine to use to render a template file).

I will implement the http method override feature and fix that issue (which is not only on jet but in general), which is quite easy, tomorrow as I am 26 hours asleep straight already... Meanwhile you can just use the .jet : https://github.com/kataras/iris/tree/master/_examples/view/template_jet_0

Actually I've just pushed a fix. go get github.com/kataras/iris@master :P I couldn't hold myself, it was so easy. Thanks @Dexus

Hello, Gerasimos,

thanks for the execution. At the moment I just stumbled across the behavior with the "extended" extensions. What I noticed when adapting the nunjucks template (in NodeJS comparable to Jet in Go) and the API.

I'm only using .jet for the first one now, so I'm looking forward to supporting several extensions soon.

Greetings, Josef

Yes, now you can register any extension (with more than one dots) - still single per one view engine. No need to implement multi for a single engine yet, if requested and needed it's easy to add it too, just give me an example engine and usage and I'll do it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kiwi2019 picture kiwi2019  路  5Comments

axetroy picture axetroy  路  4Comments

rebootcode picture rebootcode  路  3Comments

yogeshlonkar picture yogeshlonkar  路  4Comments

zfanmy picture zfanmy  路  3Comments