minad / tempel

:classical_building: TempEl - Simple templates for Emacs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Two consecutive (p ...) makes writing backward

arouene opened this issue · comments

Hello,

I'm trying to write a Jinja template like this:

(if "{% if " (p "Prefix: " pre) (p "Var: " var) " is defined %}" n
    (s var) " = {{ " (s pre) (s var) " }}" n
    "{% endif %}")

This also don't work:

(if (p "Prefix: " pre t) "{% if " (s pre) (p var) " is defined %}" n
    (s var) " = {{ " (s pre) (s var) " }}" n
    "{% endif %}")

I want to generate something like this:

{% if prefix.var is defined %}
var = {{ prefix.var }}
{% endif %}

# or like this:

{% if prefix_var is defined %}
var = {{ prefix_var }}
{% endif %}

but I end up with:

{% if ra.xiferpvVar:  is defined %}
Var:  is = {{ ra.xiferpvVar:  is }}
{% endif %}

It seems like, when two (p) or (s) are consecutive without a string to separate them, the cursor always come back to the begin of the first field.

Thanks @minad for Tempel, it's simple and yet powerfull !

Thanks. Yes, issues with consecutive fields have been reported before. These issues are problematic or even impossible to fix, since the fields also have to detect modifications right before and behind them. I treat this issue as wontfix since consecutive fields are not really useful. Either use fields separated by something or just use a single field. But if someone is willing to tackle this issue, I am happy to consider a patch.

See duplicate #55

Thanks for the answer!

It was usefull for my usecase, for having a prefix with a separator which is not fixed. But as you said usecases beside that one are probably scarce.
I would like to tackle the problem, but my elisp level is probably not good enough.

Thanks again, I'm closing the issue.