Opened 8 years ago

Last modified 4 years ago

#871 reopened enhancement

angularjs templates should have an easy means for users to customize

Reported by: cdadhemar Owned by:
Priority: major Milestone: 0.9.+
Version: 0.8.0 Keywords: web
Cc: cdadhemar@…

Description (last modified by tardyp)

Hello,

When a user wants to customize the default "layout.html" template (as an example) he/she has to copy it from the source code and modify it in the master's 'templates' directory.

It would be really great, and much more in the respect of Jinja's template inheritance spirit, that the user can "extend" a default template, using the {% extend "layout.html" %} Jinja's feature.

Note: such change is totally "binary/api compatible" for users already overriding the default "layout.html" and other default templates.

I am not sure that this request is very clear ... If not feel free to ask for more details !

Thank you very much ! Cheers, CH

Change History (9)

comment:1 Changed 8 years ago by cdadhemar

  • Cc cdadhemar@… added

comment:2 Changed 8 years ago by cdadhemar

  • Resolution set to invalid
  • Status changed from new to closed

This request is invalid since what I ask is a Sphinx dedicated feature.

What I wanted is that : http://sphinx.pocoo.org/templating.html#jinja-sphinx-templating-primer

Where I had an issue is that I just wanted to override part of the default layout.html. I created a file named "layout.html" in the master's templates directory. I then extended it :

{% extend "layout.html" %} <p>foobar</p>

This lead to an infinite loop since the template tries to extend itself ...

In Sphinx we can override a template using the same name but use the "!" prefix :

{% extend "!layout.html" %} <p>foobar</p>

This would have worked but I think this is a Sphinx feature not a generic Jinja feature ... isn't it ?

comment:3 Changed 8 years ago by dustin

  • Keywords web added
  • Milestone changed from undecided to 0.8.1
  • Resolution invalid deleted
  • Status changed from closed to reopened

It would be pretty cool if it could be made to work, though. Is there some snippet of code in Sphinx that we could use (assuming the licenses are compatible)?

comment:4 Changed 8 years ago by cdadhemar

Hello,

Thanks for reopening this request :-)

The code which do the trick is here : http://bitbucket.org/birkenfeld/sphinx/src/tip/sphinx/jinja2glue.py#cl-118

It is quite small but I have not investigated yet whether it can be easily reused within buildbot or if it is too much coupled with Sphinx internals ...

There should not be any issues on the license side. It is free software under a BSD license (according to http://pypi.python.org/pypi/Sphinx/1.0b2). The full license is here : http://bitbucket.org/birkenfeld/sphinx/src/tip/LICENSE.

I hope it helped ! Cheers, CH.

comment:5 Changed 8 years ago by dustin

  • Milestone changed from 0.8.2 to 0.8.3

comment:6 Changed 8 years ago by dustin

  • Description modified (diff)
  • Milestone changed from 0.8.3 to 0.9.+

We should offer a way to do something vaguely similar in the JS UI.

comment:7 Changed 5 years ago by dustin

  • Summary changed from user customized jinja templates should be able to extend default templates to JS UI should have an easy means for users to customize page templates

comment:8 Changed 4 years ago by tardyp

  • Description modified (diff)
  • Summary changed from JS UI should have an easy means for users to customize page templates to angularjs templates should have an easy means for users to customize

We could actually allow the user to override angularJS templates in the config['www'] section.

We could even read custom templates in a configured directory at startup/reconfig, parse them with https://pypi.python.org/pypi/pyjade/3.0.0. hoping that the syntax is fully compatible with nodejs's jade, and send that to the js in the config section.

Last edited 4 years ago by dustin (previous) (diff)

comment:9 Changed 4 years ago by dustin

Allowing the user to specify overridden templates (explicitly) seems good.

Note: See TracTickets for help on using tickets.