1
0
Fork 0
nixos-config/nixos/roles/home-assistant/jinja.nix
2022-01-09 23:32:32 +01:00

12 lines
443 B
Nix

lib: rec {
case = default: attrs: ''
{% if ${lib.concatStringsSep "\n{% elseif " (lib.mapAttrsToList (condition: result: "${condition} %}\n ${result}") attrs)}
{% else %}
${default}
{% endif %}
'';
if' = condition: ifTrue: ifFalse: case ifFalse { ${condition} = ifTrue; };
or = lhs: rhs: "(${lhs} or ${rhs})";
and = lhs: rhs: "(${lhs} and ${rhs})";
isState = entity: state: "is_state('${entity}','${state}')";
}