mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
Create a new template function: capitalize
Update documentation Update changelog
This commit is contained in:
parent
b2360461d0
commit
0b067e9f5b
4 changed files with 12 additions and 0 deletions
|
|
@ -1783,6 +1783,11 @@ class DefaultTemplateFunctions:
|
||||||
"""Convert a string to upper case."""
|
"""Convert a string to upper case."""
|
||||||
return s.upper()
|
return s.upper()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def tmpl_capitalize(s):
|
||||||
|
"""Converts to a capitalized string."""
|
||||||
|
return s.capitalize()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def tmpl_title(s):
|
def tmpl_title(s):
|
||||||
"""Convert a string to title case."""
|
"""Convert a string to title case."""
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ Changelog goes here! Please add your entry to the bottom of one of the lists bel
|
||||||
|
|
||||||
New features:
|
New features:
|
||||||
|
|
||||||
|
* New template function added: ``%capitalize``. Converts the first letter of
|
||||||
|
the text to uppercase and the rest to lowercase.
|
||||||
* Ability to query albums with track db fields and vice-versa, for example
|
* Ability to query albums with track db fields and vice-versa, for example
|
||||||
`beet list -a title:something` or `beet list artpath:cover`. Consequently
|
`beet list -a title:something` or `beet list artpath:cover`. Consequently
|
||||||
album queries involving `path` field have been sped up, like `beet list -a
|
album queries involving `path` field have been sped up, like `beet list -a
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ These functions are built in to beets:
|
||||||
|
|
||||||
* ``%lower{text}``: Convert ``text`` to lowercase.
|
* ``%lower{text}``: Convert ``text`` to lowercase.
|
||||||
* ``%upper{text}``: Convert ``text`` to UPPERCASE.
|
* ``%upper{text}``: Convert ``text`` to UPPERCASE.
|
||||||
|
* ``%capitalize{text}``: Make the first letter of ``text`` UPPERCASE and the rest lowercase.
|
||||||
* ``%title{text}``: Convert ``text`` to Title Case.
|
* ``%title{text}``: Convert ``text`` to Title Case.
|
||||||
* ``%left{text,n}``: Return the first ``n`` characters of ``text``.
|
* ``%left{text,n}``: Return the first ``n`` characters of ``text``.
|
||||||
* ``%right{text,n}``: Return the last ``n`` characters of ``text``.
|
* ``%right{text,n}``: Return the last ``n`` characters of ``text``.
|
||||||
|
|
|
||||||
|
|
@ -629,6 +629,10 @@ class DestinationFunctionTest(BeetsTestCase, PathFormattingMixin):
|
||||||
self._setf("%upper{$title}")
|
self._setf("%upper{$title}")
|
||||||
self._assert_dest(b"/base/THE TITLE")
|
self._assert_dest(b"/base/THE TITLE")
|
||||||
|
|
||||||
|
def test_capitalize_variable(self):
|
||||||
|
self._setf("%capitalize{$title}")
|
||||||
|
self._assert_dest(b"/base/The title")
|
||||||
|
|
||||||
def test_title_case_variable(self):
|
def test_title_case_variable(self):
|
||||||
self._setf("%title{$title}")
|
self._setf("%title{$title}")
|
||||||
self._assert_dest(b"/base/The Title")
|
self._assert_dest(b"/base/The Title")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue