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

Suggestion qtc: Add a watcher qtc -w #7

Closed
ghost opened this issue May 12, 2016 · 8 comments
Closed

Suggestion qtc: Add a watcher qtc -w #7

ghost opened this issue May 12, 2016 · 8 comments

Comments

@ghost
Copy link

ghost commented May 12, 2016

Add a watcher subcommand/flag for example qtc -w ./ -d ./templates -> watch and compile on file changes in the current directory, serve the compiled files in the ./templates directory.

You can use fsnotify package, I will do that on iris but it will be nice to have it build'n with qtc :)

P.S: I don't know if go generate has a watch command but I doubt

@ghost ghost changed the title Suggestion: Add a watcher qtc -w Suggestion qtc: Add a watcher qtc -w May 12, 2016
@nkev
Copy link

nkev commented May 17, 2016

I'm not sure how this would work. Quicktemplate only creates *.go files by running go generate. You could automate that with fsnotify but then you also have to recompile the whole application right?

@valyala
Copy link
Owner

valyala commented May 17, 2016

This requires recompilation of the whole application. I doubt qtc is a good level for such a functionality. Probably a separate watcher app may be created instead for automatic recompilation on template files' modifications.

@nkev
Copy link

nkev commented May 17, 2016

@valyala Yes, this is a problem with most of the good Go templating engines, except the ones that don't generate source code (like Jet). Every time you make the smallest change in any template, you have to run go generate and then recompile the whole app. I looked at Jet, but it uses reflection, which I hate. Would you consider adding basic include, for-each and if-then functionality to Fasttemplate? That's all we really need.

@ghost
Copy link
Author

ghost commented May 18, 2016

Yes, you're right , the whole application needs to be re-compiled... I'm closing this issue and sorry I should know that

@ghost ghost closed this as completed May 18, 2016
@valyala
Copy link
Owner

valyala commented May 18, 2016

Would you consider adding basic include, for-each and if-then functionality to Fasttemplate?

I don't want complicating fasttemplate. So it would be better just using Jet. It looks like it is the fastest template engine for go at the moment, which doesn't require source code recompilation after each modification.

@stereosteve
Copy link
Contributor

stereosteve commented Jun 2, 2016

modd is a nice tool I just found to handle this.

Here is my modd.conf file for quicktemplate:

**/*.qtpl {
    prep: qtc
}

**/*.go {
    prep: go build -o devbuild
    daemon: ./devbuild
}

devbuild {
    daemon: devd --livewatch --modd http://localhost:8080
}

With this setup changing a single .qtpl file will recompile everything and restart the server.

The last part at the bottom uses devd from the same author to work with livereload. That part can be removed if you don't want livereload.

@valyala
Copy link
Owner

valyala commented Jun 2, 2016

@stereosteve , this is awesome!

@stereosteve
Copy link
Contributor

@valyala thanks for quicktemplate! It is so much better than text/template. If I could double star it I would.

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

No branches or pull requests

3 participants