Open PodsBot opened 8 years ago
Follow-up, see what Metaplate can do with it's templating, how much of this can it do?
+1
Those comparison operators would be very useful when creating pods templates. +1
This format and design sounds more like Twig/Timber Templating support: https://www.upstatement.com/timber/
This format and design sounds more like Twig/Timber Templating support: upstatement.com/timber
Agreed.
One extreme option, if BC is going to break anyway, would be to pull Timber in as a dependency, and just pass the Pods Template content through Timber::render()
(or whatever is needed) instead. Twig is far more established as a templating language than the Pods Template language, and may also ease adoption.
Maybe allow Pods Templates to choose which templating engine it should use, so that existing sites aren't forced to update the contents of their templates, and could switch over templates one at a time when they wanted to make use of the more advanced features?
@GaryJones Great idea! We would definitely want to put a "freeze" on the current iteration of Template Language handling and provide the Timber as a smoother transition path with better handling for loops and conditionals for those people that still don't want to use PHP.
The setting could either be at a Pods Admin, Settings level or on a template by template basis possibly.
Do you know if the CodeMirror library we currently use has 'code assist and syntax highlighting' for Twig/Timber templating?
Anything that improves the Templates would be great - important thing to keep in mind is that the template/magic tag stuff is used in shortcodes - and one other thing - how does Gutenberg play into all of it - https://wordpress.org/gutenberg/handbook/templates/ ?
Do you know if the CodeMirror library we currently use has 'code assist and syntax highlighting' for Twig/Timber templating?
I assume it's this: https://codemirror.net/mode/twig/. I'm not sure if Timber adds any more Twig-like syntax on top, which may miss the syntax highlighting.
Related reading: https://notlaura.com/the-twig-for-timber-cheatsheet/ by @laras126 who I recently met at WCEU and who may know the answer to the above :-)
Templates in Gutenberg are basically pre-configured 'content blocks'. Our implementation of Templates, whether Auto Templates are placed by Shortcodes would be identical. Improvements on the process would be to identify Pods Templates based on Post Type and providing them as Template blocks to drop based on Content Type.
+1 for this functionality.
+1
Discussion on replacing current Template Tags
[if][else][/if]
, etc. with a non-shortcode style and adding Comparison operators to the if conditionals. Add additional items to include in this feature as we find them. Also close and reference any other issues that are similar to this request here.Basic operators
{@if <conditional>}}
{@elseif <conditional>}
- Implemented within corresponding{@if}{@/if}
{@else}
- Implemented within corresponding{@if}{@/if}
{@each field_name}
- Loop through values of a relationship / file / taxonomy field{@each field_name orderby="field"}
- Loop through values of a relationship / file / taxonomy field (with orderby)Conditionals:
field_name
- Non-empty value check! field_name
- Empty value checkfield_name == "Value"
- Value equals checkfield_name != "Value"
- Value does not equal checkfield_name == other_field
- Value equals check on another fieldfield_name != other_field
- Value does not equal check on another fieldnth(#)
- :nth-child() type of functionality - see: http://www.w3schools.com/cssref/sel_nth-child.aspzebra()
- Every other row in the loopComparison operators (numeric or compare another field): http://php.net/manual/en/language.operators.comparison.php
field_name == 1
field_name = 1
(same as above, for more complete coverage)field_name != 1
field_name <> 1
(same as above, for more complete coverage)field_name === 1
field_name !== 1
field_name < 1
field_name <= 1
field_name > 1
field_name >= 1
Logical Operators (with no nesting support): http://php.net/manual/en/language.operators.logical.php
field_name = 1 && other_field_name = 2
field_name = 1 AND other_field_name = 2
(same as above, for more complete coverage)field_name = 1 || other_field_name = 2
field_name = 1 OR other_field_name = 2
(same as above, for more complete coverage)Additional things to be figured out:
{@today}
,{@cur_date}
, etc.Special tags to add into field():
{@_total}
- Total count of the loop{@_total_found}
- Total Found in the result set{@_position}
- Current position in the loop starting at 1