#6374 closed enhancement (fixed)
get rid of macros.html in favor of xi:include'd snippets
Reported by: | Owned by: | Remy Blank | |
---|---|---|---|
Priority: | normal | Milestone: | 0.12 |
Component: | rendering | Version: | devel |
Severity: | normal | Keywords: | genshi needmajor |
Cc: | mmitar@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
I needed a way to modify the generated list of attachments in 0.11. Currently the best way to do that seems to be to put a customized version of macros.html in a site's templates directory. I'd prefer not to fork that whole file for a minor change. What I'd rather do is override the macro definitions before they are called.
One solution to this is to add a site_macros.html file, similar to the site.html file used by layout.html. site_macros.html could be included by macros.html and allow a site to override and customize the macro. I've attached a patch to do that simple include.
Additionally, the current show_one_attachment() macro is nested in list_of_attachments() which makes it difficult to override. I've attached a second patch that reorganizes the macro definitions so you can override just show_one_attachment() by itself.
Either or both of these patches will make it easier to customize the output of the macros.
Attachments (2)
Change History (19)
by , 17 years ago
Attachment: | trac-site-macros.diff added |
---|
by , 17 years ago
Attachment: | trac-attachment-macros.diff added |
---|
comment:1 by , 17 years ago
Keywords: | genshi added |
---|---|
Milestone: | → 0.11 |
comment:2 by , 17 years ago
Component: | general → rendering |
---|---|
Owner: | changed from | to
comment:3 by , 17 years ago
Great. Breaking up the macros into includes would make things easier to override.
I had thought about using a template filter, or <py:match> to modify the content after it had been generated. But specifically with attachments there isn't a good path to match to get the rendered list of attachments.
If the H3 and UL for the attachments on the wiki page were wrapped in a <div id="attachmentlist"> it would be easier to do that. The "not compact" attachment list does have a div with id="attachments" but it comes after the <h2>Attachments</h2>.
What would be the best way to get more structural XHTML markup information available for Genshi filters to act against?
comment:4 by , 17 years ago
Will perhaps make it for 0.11, but not for beta1.
In the meantime, I added a warning (r6251).
comment:6 by , 15 years ago
Keywords: | needmajor added |
---|---|
Milestone: | 0.13 → 0.12 |
Would be nice to get rid of macros.html…
comment:8 by , 15 years ago
Summary: | [PATCH] Provide a cleaner way to override macros → get rid of macros.html in favor of xi:include'd snippets |
---|
Note that as we get more templates, we should probably increase the default Genshi template loader cache size.
comment:9 by , 15 years ago
The default size of the template cache was increased from 25 to 128 in [9251]. We currently have 65 templates on trunk, and the cache gets quickly filled to 50 or so just by clicking around in my test environment. Considering most people install at least a few plugins, 128 seems like a reasonable value (it's maybe a bit high, but I would be surprised if templates took that much memory, and people with memory constraints can easily lower the value).
Next I'll see if I can reasonably get rid of macros.html
altogether.
follow-up: 14 comment:10 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Removed all uses of the macros in macros.html
and macros.rss
in [9260]. The files are kept for backward compatibility (until 0.13), and <xi:include>
the snippets (a very nice idea by osimons).
comment:11 by , 15 years ago
Owner: | changed from | to
---|
follow-up: 13 comment:12 by , 15 years ago
So now it is enough just to change one small snippet, for example to change generated list of attachments, and not complete macros.html? And one can change this snippet by overriding it with a custom version with a file in templates
dir?
comment:13 by , 15 years ago
Replying to Mitar:
So now it is enough just to change one small snippet, for example to change generated list of attachments, and not complete macros.html? And one can change this snippet by overriding it with a custom version with a file in
templates
dir?
Yes, this should be the case. Please let us know if that doesn't work for you.
comment:14 by , 10 years ago
Replying to rblank:
Removed all uses of the macros in
macros.html
andmacros.rss
in [9260]. The files are kept for backward compatibility (until 0.13), and<xi:include>
the snippets (a very nice idea by osimons).
In comment:15:ticket:11494 I've proposed to remove the files for Trac 1.1.2.
follow-up: 16 comment:15 by , 10 years ago
Looks like [12889] could have left a prevnext_nav.html
snippet behind…
follow-up: 17 comment:16 by , 10 years ago
Replying to cboos:
Looks like [12889] could have left a
prevnext_nav.html
snippet behind…
Is that used by a plugin? I thought it should be replaced by: trunk/trac/web/chrome.py@13203:221#L212.
comment:17 by , 10 years ago
Replying to rjollos:
Replying to cboos:
Looks like [12889] could have left a
prevnext_nav.html
snippet behind…Is that used by a plugin? I thought it should be replaced by: trunk/trac/web/chrome.py@13203:221#L212.
You're right, this should probably do… the only thing we'll lose in the SpamFilter (#11807) is the prev/next links duplicated at the bottom of the page.
Well, actually what we're going to do is to remove the macros completely and use instead snippets to be <py:include>d. It could also make your use case (overriding) easier to achieve, even if in that specific case (override the
show_one_attachment
part), a template filter might be more appropriate (have a look at source:trunk/sample-plugins/ticket_clone.py@6153).cmlenz told me that he's even considering removing the <py:def> altogether in future Genshi releases.
It might be nice to get this done before 0.11, so people wouldn't expect the macros to be there, or at the very least add a warning there…
We need a "rendering" component, btw.