[mythtv-theming] Possible minor template issue

Stuart Morgan stuart at tase.co.uk
Fri Sep 24 16:05:38 UTC 2010


On Friday 24 Sep 2010 15:29:26 David Engel wrote:
> I see a number of theme templates like the following.
> 
> 	%|"SUBTITLE|"% %STARS% %DESCRIPTION%
> 	%|"SUBTITLE|"%\n%YEARSTARS%%DESCRIPTION%
> 
> Shouldn't they be like this instead?
> 
>         %|"SUBTITLE|" %%STARS| %%DESCRIPTION%
>         %|"SUBTITLE|"\n%%YEARSTARS%%DESCRIPTION%

In current trunk, after changes made within the week they can and should be:

         %"|SUBTITLE|" %%STARS| %%DESCRIPTION%
         %"|SUBTITLE|"\n%%YEARSTARS%%DESCRIPTION%

Although your suggestion would work for backwards compatibility reasons.

With the new regexp any number of characters are permitted between 
"%<prepend>|" preceding the inserted string and "|<append>%" following the 
string.

e.g. %Episode: |SUBTITLE|\n%%"|DESCRIPTION|"% would produce

Episode: The Accident
"Jack and Jill went up the hill to fetch a pail of water"

> It's been a very long time since I added that leading/trailing feature
> to field replacement, so perhaps it no longer works the way I think it
> does.

IIRC the original regular expression in the old UI required the following 
form:

%SUBTITLE|"|"%

and it only supported a single character to be prepended/appended.

The mythui conversion changed the regexp slightly so that the prepended 
character appeared at the beginning because this seemed a little clearer. 
However it still only permitted a single character because I was having 
trouble with the regexp, but I'd always intended to come back to it and allow 
multiple characters. About a week ago I remembered that I had yet to fix the 
regexp and this was finally done in [26412] ([26418] & [26451])

The template stuff in MythUI actually supports two methods, the choice of 
which probably depends on the usage.

Take the following example:
<textarea name="subtitle">
    <value>Unknown Episode</value> <!-- A default string, shown when subtitle 
is empty -->
    <template>Episode: %1</template>
</textarea>

When you have a single value in the textarea or the value does not come from a 
map you may choose the above form. Benefits include the ability to show 
something in place of the subtitle if no subtitle is available.

When you want to join multiple strings together, then your only choice is the 
%<prefix>|VALUE|<suffix>% format.

Also worth mentioning is the plural translation form for numeric values.

<textarea name="timeleft">
    <template>There is %n second(s) remaining</template>
</textarea>

This will appear as a special 'plural' string to translators and once 
translated it will be displayed as:
"There is 1 second remaining"
"There are 3 seconds remaining"
-- 
Stuart Morgan


More information about the mythtv-theming mailing list