Template begin/end comments



  • A feature that MyBB has which I found to be pretty useful was the ability to toggle comments at the beginning and the end of templates. These comments can be switched on and off via ACP and make development/bugfixing a lot easier, especially at the beginning.
    For NodeBB, I imagined it like this:

    <!-- START nodebb-theme-lavender/account/profile.tpl -->
    
    { template content }
    
    <!-- END nodebb-theme-lavender/account/profile.tpl -->
    

    Thoughts?


  • Plugin & Theme Dev

    Do you have an example of what you're talking about? I'm not quite sure I understand.


  • Admin

    Did you mean to say that every template have a "begin" and "end" HTML comment, so you can see it in the HTML source?

    There's pretty much no need -- the contents of each page's template is placed inside #content. That's the direct parent.

    Snippets of templates are imported as "partials", but you'll be able to see the <!-- IMPORT --> line in the template that imported it, so this should also not be much of an issue...


  • Plugin & Theme Dev

    @julian you see the import-comment within the template but I agree with @Moritz-Friedrich that it would be neat for some developers to have such <!-- IMPORT xyz --> <!-- END IMPORT xyz --> comments within the actual html outcome iff activated via ACP.

    This way you can directly search mistakes within that partial instead of searching the relevant tag within the main-template first thus needing to traverse into the relevant partial (especially if recursive imports are possible).
    Could be helpful, no reason not to add (since it's a self-maintained template-engine) as to my view.



  • Could be a developer mode that shows the template paths, similar to Magento and it's &tp=1 to show:

    Mage

    But perhaps within the source code. 👍



  • @a_5mith , yes, that is what I meant - those comments would be pretty ugly in production code, but to debug your own templates it would be nice to see where something comes from straight out of the browser. Especially when you - like me - just started working with NodeBB. 🙂


 

Suggested Topics

| |