krzysztofzablocki/Sourcery

Unknown template tag 'else'

Closed this issue · 1 comments

After upgrading to 0.16.0 I faced with the error from the topic above.
Having a template lens.stencil:

import UIKit

// MARK: - Generated bound lenses

{% for type in types.implementing.AutoLensImplementing %}
struct BoundLensTo{{ type.name|replace:".","" }}<Whole>: BoundLensType {
    typealias Part = {{ type.name }}
    let boundLensStorage: BoundLensStorage<Whole, Part>
    {% for variable in type.storedVariables %}
    var {{ variable.name }}: BoundLens<Whole, {% if variable.type.parent == nil %}{{variable.typeName}}{% else %}{{ type.name }}.{{variable.typeName}}{% endif %}> {
        return BoundLens<Whole, {% if variable.type.parent == nil %}{{variable.typeName}}{% else %}{{ type.name }}.{{variable.typeName}}{% endif %}>(parent: self, sublens: {{ type.name }}.Lenses.{{ variable.name }})
    }{% endfor %}
}
{% endfor %}

and having this output when running sourcery:

$ ./Pods/Sourcery/bin/sourcery 
Using configuration file at '.sourcery.yml'
Scanning sources...
Found 912 types.
Loading templates...
Loaded 2 templates.
Generating code...
error: path/to/lens.stencil: Unknown template tag 'else'

I also tried to put the contents of few templates from the repo, like /master/Sourcery/Templates/Description.stencil into this file and got various e

lens.stencil: Unknown template tag 'endfor'

But! When I set a template like this:

import UIKit

// MARK: - Generated lenses

{% for type in types.implementing.AutoLensImplementing %}
/// :nodoc:
extension {{ type.name }} {
    struct Lenses { {% for variable in type.storedVariables %}
      static let {{ variable.name }} = Lens<{{ type.name }}, {{variable.typeName}}>(
        get: { $0.{{variable.name}} },
        set: { (newValue, oldValue) in
           {{type.name}}({% for argument in type.storedVariables %}{{argument.name}}: {% if variable.name == argument.name %}newValue{% else %}oldValue.{{argument.name}}{% endif %}{% if not forloop.last%}, {% endif %}{% endfor %})
        }
      ){% endfor %}
    }
}
{% endfor %}

then no error is occur.

It was working fine in previous version. What do I do wrong?

Hi @Sega-Zero . This probably would be better to raise as an issue in Stencil project.