Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add combine operator to template language #1453

Closed
RhetTbull opened this issue Mar 24, 2024 · 0 comments
Closed

Add combine operator to template language #1453

RhetTbull opened this issue Mar 24, 2024 · 0 comments
Labels
feature request New feature or request

Comments

@RhetTbull
Copy link
Owner

See this reddit post. The ability to combine two multi-value templates into a new list of values would be useful inside the template language.

New syntax:
`"pretext{delim+template_field:subfield(field_arg)|filter[find,replace] conditional&combine_value?bool_value,default}posttext"

&combine_value: Template fields may be combined with another template statement to return multiple values. The combine_value is another template statement. For example, the template {created.year&{folder_album,}} would resolve to ["1999", "Vacation"] if the photo was created in 1999 and was in the album Vacation. Because the combine_value is a template statement, multiple templates may be combined together by nesting the combine operator: {template1&{template2&{template3,},},}. In this example, a null default value is used to prevent the default value from being combined if any of the nested templates does not resolve to a value

Another use case for variables is filtering combined template values. For example, using the &combine_value mechanism to combine two template values that might result in duplicate values, you could do the following: {var:myvar,{template1&{template2,},}}{%myvar|uniq} which allows the use of the uniq filter against the combined template values.

@RhetTbull RhetTbull added the feature request New feature or request label Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant