mirror of
https://github.com/beetbox/beets.git
synced 2025-12-30 12:32:33 +01:00
doc fixes for extensible template fields
This commit is contained in:
parent
91901fc379
commit
69c0e8d496
2 changed files with 11 additions and 7 deletions
|
|
@ -263,7 +263,7 @@ Add Path Format Functions and Fields
|
|||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Beets supports *function calls* in its path format syntax (see
|
||||
:doc:`/reference/pathformat`. Beets includes a few built-in functions, but
|
||||
:doc:`/reference/pathformat`). Beets includes a few built-in functions, but
|
||||
plugins can add new functions using the ``template_func`` decorator. To use it,
|
||||
decorate a function with ``MyPlugin.template_func("name")`` where ``name`` is
|
||||
the name of the function as it should appear in template strings.
|
||||
|
|
@ -288,13 +288,16 @@ Plugins can also add template *fields*, which are computed values referenced as
|
|||
parameter, ``item``, with ``MyPlugin.template_field("name")``. Here's an example
|
||||
that adds a ``$disc_and_track`` field::
|
||||
|
||||
@MyPlugin.template_value('disc_and_track')
|
||||
@MyPlugin.template_field('disc_and_track')
|
||||
def _tmpl_disc_and_track(item):
|
||||
"""Expand to the disc number and track number if both are
|
||||
sepcified. If there's no disc number, then just exapnds to the
|
||||
track number.
|
||||
"""Expand to the disc number and track number if this is a
|
||||
multi-disc release. Otherwise, just exapnds to the track
|
||||
number.
|
||||
"""
|
||||
if item.disc:
|
||||
if item.disctotal > 1:
|
||||
return u'%02i.%02i' % (item.disc, item.track)
|
||||
else:
|
||||
return u'%02i' % (item.track)
|
||||
|
||||
With this plugin enabled, templates can reference ``$disc_and_track`` as they
|
||||
can any standard metadata field.
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ Available Values
|
|||
|
||||
Here's a (comprehensive?) list of the different values available to path
|
||||
formats. (I will try to keep it up to date, but I might forget. The current list
|
||||
can be found definitively `in the source`_.)
|
||||
can be found definitively `in the source`_.) Note that plugins can add new (or
|
||||
replace existing) template values (see :ref:`writing-plugins`).
|
||||
|
||||
.. _in the source:
|
||||
http://code.google.com/p/beets/source/browse/beets/library.py#36
|
||||
|
|
|
|||
Loading…
Reference in a new issue