mikestefanello / pagoda

Rapid, easy full-stack web development starter kit in Go
MIT License
2.18k stars 114 forks source link

How to use pongo2 as default template engine. #29

Closed ErSauravAdhikari closed 1 year ago

ErSauravAdhikari commented 1 year ago

I love pagoda. It's an excellent piece of software.

However, I do feel like the default template engine from Golang std lib is quite limited. Specially since, HTMX could benefit from a lot of features not found in go's official templating library.

Hence, I wanted to use Pongo2 (Similar to Django's template engine). How do I go about that?

ErSauravAdhikari commented 1 year ago

https://github.com/flosch/pongo2

mikestefanello commented 1 year ago

Hey - thank you! I'm glad to hear it's been useful for you. I'm hoping to finally have some time to get back to working on it soon. I have some ideas for improvements, etc.

I've never used Pongo2, or any alternative template engine. The nice thing about Pagoda is that all template operations are isolated to the Template renderer. You should be able to make changes in there to use Pongo2 rather than the standard library's template package. You may also need to adjust some of the constants in the config package.

Give that a try and report back. It would be good to document what you tried here so others who want to use Pongo2 can have this as a reference.

gedw99 commented 1 year ago

I am using Po go also @ErSauravAdhikari

@mikestefanello Is this something you would take a PR for or do you not want it in this repo ?

mikestefanello commented 1 year ago

@gedw99 I don't think so unless there was a really compelling reason to include it over the standard template library; and over the other alternatives. It would be good to provide some documentation here to explain how to perform this replacement. If the procedure is very similar for other template libraries, I can include instructions in the README.

ErSauravAdhikari commented 1 year ago

I am using Po go also @ErSauravAdhikari

@mikestefanello Is this something you would take a PR for or do you not want it in this repo ?

Hmm, could you please dive more deeper into how you integrated pongo in pagoda system? (Assuming po go is a typo)

@mikestefanello Thanks, I'll check the template renderer and config out.

gedw99 commented 1 year ago

@mikestefanello will do...

@ErSauravAdhikari you want to know how to get it rolling ?

ErSauravAdhikari commented 1 year ago

@mikestefanello will do...

@ErSauravAdhikari you want to know how to get it rolling ?

Yeah!

gedw99 commented 1 year ago

I am doing it this way...

https://github.com/mikestefanello/pagoda/blob/main/pkg/services/template_renderer.go is the current one.

Make a new one called for example "services/template__pongo2_renderer.go"

Then implement the calls... to https://github.com/flosch/pongo2

ErSauravAdhikari commented 1 year ago

I am doing it this way...

https://github.com/mikestefanello/pagoda/blob/main/pkg/services/template_renderer.go is the current one.

Make a new one called for example "services/template__pongo2_renderer.go"

Then implement the calls... to https://github.com/flosch/pongo2

If possible can you share the template__pongo2renderer in a gist [1]_ or sth similar?

1: https://gist.github.com/

gedw99 commented 1 year ago

when i am finished I will put on github and then put the link here.

wont be for a while though.

ErSauravAdhikari commented 1 year ago

when i am finished I will put on github and then put the link here.

wont be for a while though.

Alright, thanks.