posativ / acrylamid

(unmaintained) static blog generator in python with incremental rendering ⛺
http://posativ.org/acrylamid/
Other
277 stars 40 forks source link

Entry variable is not recognized but Acrylamid compiles the file properly #227

Open andreamoro opened 9 years ago

andreamoro commented 9 years ago

This is a strange issue that I got since I have updated to the latest version using the github master.

I have an entry with a new variable defined in the YAML front matter. In my template I've recalled the variable with a {{ entry.variable }}

As soon as Acrylamid compiles the code, the following error is returned

File "Jump/main.html", line 29, in block "content"
    <h1 id="title" class="Print">{{ entry.headertitle }}</h1>
File "/Users/andreamoro/VirtualEnvs/JumpAcrylamid/lib/python2.7/site-packages/jinja2/environment.py", line 397, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'entry' is undefined

However, having a look at the output the variable is rendered correctly.

This problem exists with Jinja 2.7.3 whereas it seems fine with Jinja 2.6

posativ commented 9 years ago

The entry object is only available in the template for a single entry, by default entry.html.

andreamoro commented 9 years ago

Well, but if I do something like this

            {%- if entry is defined %}
            <h1 id="title" class="Print">{{ entry.headertitle | e }}</h1>
            <h2 id="subtitle" class="Print">{{ entry.headersubtitle | e }}</h2>
            {%- endif %} 

I got the compiler going through with the correct replacement and I'm not in an entry.

posativ commented 9 years ago

Ah my bad. Can you show me your conf.py?

andreamoro commented 9 years ago

Well, actually the view page inherit from entry, so technically the entry exists in the context. Anyway, below there is the bit that you may be interested into. It's not a big deal, it's just for me to understand.

'/:slug': {
    'view': 'page',
    'template': 'main.html'  # default, includes entry.html
},