Replies: 3 comments 2 replies
-
How complex should the conditions for the template
|
Beta Was this translation helpful? Give feedback.
-
Was wondering lately about adding something to make the syntax more readable or simpler for negation. Current: <template if="audio == null">
<template if="streamType == 'live'">
<template if="targetLiveWindow == 0">
<template if="breakpointSm == null">
<media-control-bar slot="top-chrome">
{{>LiveButton}}
</media-control-bar>
<media-control-bar>
{{>PlayButton}}
</media-control-bar>
</template>
<template if="breakpointSm">
<template if="breakpointMd == null"> Proposal: Add a <template unless="audio">
<template if="streamType == 'live'">
<template unless="targetLiveWindow">
<template unless="breakpointSm">
<media-control-bar slot="top-chrome">
{{>LiveButton}}
</media-control-bar>
<media-control-bar>
{{>PlayButton}}
</media-control-bar>
</template>
<template if="breakpointSm">
<template unless="breakpointMd"> Alternative: Add a <template if="not audio">
<template if="streamType == 'live'">
<template if="not targetLiveWindow">
<template if="not breakpointSm">
<media-control-bar slot="top-chrome">
{{>LiveButton}}
</media-control-bar>
<media-control-bar>
{{>PlayButton}}
</media-control-bar>
</template>
<template if="breakpointSm">
<template if="not breakpointMd"> |
Beta Was this translation helpful? Give feedback.
-
worth a look for inspiration Go templates! https://pkg.go.dev/text/template |
Beta Was this translation helpful? Give feedback.
-
Themes are
<template>
s, that use a templating language built on the template parts proposal.This is a thread to discuss what functionality is required and what the syntax should look like.
The following basic concepts are already included but could potentially change syntax in the future.
Note that this syntax is heavily inspired by Mustache, Handlebars, Nunjucks, Liquid, etc.
Variables
The most basic tag type is the variable. A
{{name}}
tag in a basic template will try to find the name key in the current state that is derived from the<media-theme>
attributes. Variables are escaped by default.If you like to provide a fallback for a variable that might be empty, this can be done like so
{{name ?? 'Frank'}}
Partials
Partials are defined by using an inner
<template>
element with apartial
attribute which is set to a unique name in your theme.These can then be used in other places in the theme with a partial variable like so
{{>PlayButton}}
They can also accept params by adding them after the var name
{{>PlayButton section="center"}}
Conditionals
When a single element or a multiple elements need to be left out from the theme when certain conditions are met it's possible to use a conditional. A conditional is also defined by an inner template with a
if
attribute. The value of thisif
attribute can be a simple equality check or just a empty check.Beta Was this translation helpful? Give feedback.
All reactions