Skip to content

nested variable assignment not working #4

@voko

Description

@voko
:each image in getCollection('galleryimages').toJSON()
    .col-md-4
        %h3= image.heading
        :if image.gallery == 'landing'
            %p= image.image
            - var test = image.url

The variable assignmentin the last line - var test = image.url breaks the generation.

docpad itself does not report an error, yet in the generated HTML, this error message is shown:

SyntaxError: Unexpected token ;
  at Function.<anonymous> (/Users/volker/Documents/20_coding/01_projects/kohchanginfo/html/node_modules/docpad-plugin-haml/node_modules/haml/lib/haml.js:595:29)
  at execute (/Users/volker/Documents/20_coding/01_projects/kohchanginfo/html/node_modules/docpad-plugin-haml/node_modules/haml/lib/haml.js:602:8)
  at Function.render (/Users/volker/Documents/20_coding/01_projects/kohchanginfo/html/node_modules/docpad-plugin-haml/node_modules/haml/lib/haml.js:587:12)
  at HamlPlugin.render (/Users/volker/Documents/20_coding/01_projects/kohchanginfo/html/node_modules/docpad-plugin-haml/out/haml.plugin.js:22:29)
  at ambi (/Users/volker/Documents/20_coding/01_projects/kohchanginfo/html/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:55:18)
  at Task.<anonymous> (/Users/volker/Documents/20_coding/01_projects/kohchanginfo/html/node_modules/docpad/node_modules/event-emitter-grouped/out/lib/event-emitter-grouped.js:45:23)
  at ambi (/Users/volker/Documents/20_coding/01_projects/kohchanginfo/html/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:55:18)
  at fire (/Users/volker/Documents/20_coding/01_projects/kohchanginfo/html/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:384:27)
  at b (domain.js:183:18)
  at Domain.run (domain.js:123:23)
  at Task.fire (/Users/volker/Documents/20_coding/01_projects/kohchanginfo/html/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:398:25)
  at Object._onImmediate (/Users/volker/Documents/20_coding/01_projects/kohchanginfo/html/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:414:26)
  at processImmediate [as _immediateCallback] (timers.js:336:15)

When removig the last line, html is generated correctly.
not indenting the variable definition line will execute, but not as part of the :if or :each clauses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions