Skip to content

Unexpected template-style behavior with default  #55

@xpe

Description

@xpe

First, thanks for sigil. I prefer it already to envsubst and shell evaluation.

% print "{{ \$x | default \"foo\" }}" | tee template
{{ $x | default "foo" }}

This did not behave as I expected:

% sigil -f template
template: template:1: undefined variable "$x"

Interestingly, in this case, the default works:

% sigil -f template x=
foo

Regular behavior, of course, is fine:

% sigil -f template x=bar
bar

I'm using sigil 0.6.0 on macOS.

Now, after reading how Hugo does templating, I tried using $.x instead of $x, and...

% print "{{ \$.x | default \"foo\" }}" | tee template
{{ $.x | default "foo" }}
% sigil -f template
foo

Ok, this is the result I wanted, but it took a lot of horsing around.

At the least, I'd suggest more documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions