XF 2.0 Developing with A LOT of Templates? Best Practices?

robdog

Well-known member
I am finding that my templates.xml file is getting rather large. What is the best way to develop templates? Has anyone created a script that allows for templates to be built in separate files and then compiled into the larger templates.xml? Or do most of you guys just build/change templates inside the actual XenForo app?
 
I think you are talking about a style or theme right? I am more referring to a bunch of templates for an addon. Or does what you said work for both?
 
Unfortunately, I am trying to figure out how to edit template outside of the ACP. Tools like Sublime are a really good editor, and I would prefer to use those. Anyways, I'll see if I can write some sort of NPM script to watch a templates directory then compile all templates into a single templates.xml and get ready for a "rebuild" of the addon that I am building. (very massive addon, lol)
 
I think you probably need to backtrack a little bit and look through that developer documentation, if you haven't already.

Enabling development mode will allow you to store templates and other development related data as files. Templates specifically are editable in the file system, and we have a watcher system which will watch the template output for changes and then automatically import those changes on page load.

The templates.xml file is the very last thing you need to worry about. This only needs to be written when you're releasing the add-on, and we have tools that will build the add-on into a releaseable ZIP for you.
 
Unfortunately, I am trying to figure out how to edit template outside of the ACP. Tools like Sublime are a really good editor, and I would prefer to use those. Anyways, I'll see if I can write some sort of NPM script to watch a templates directory then compile all templates into a single templates.xml and get ready for a "rebuild" of the addon that I am building. (very massive addon, lol)
Enabling Development mode will do exactly that for you. It will store your templates as files in the /src/addons/*your_addon*/_output/templates folder and read changes from these files as Chris has just described above.
 
Okay, this is great. Just ran the export and it is watching the directory now! I've been doing manual rebuilds the entire time, lol.

Does this also watch changes to the JSON files or is that something that needs to be imported through the CLI?

Thanks for the help guys.
 
Back
Top Bottom