Amber: partial not expected behavior

Created on 15 May 2018  路  5Comments  路  Source: amberframework/amber

Description

if create subfolder at layouts and copy there files: _nav.slang and application.slang
and change at layouts/portal/application.slang path of render:
== render(partial: "layouts/portal/_nav.slang")

appears error

Steps to Reproduce

  1. copy application.slang and _nav.slang to folder at layouts
  2. try to render partial _nav.slang:
    == render(partial: "layouts/portal/_nav.slang")

Expected behavior: it will render partial

Actual behavior: Shows error

Reproduces how often: always

Versions

Amber 0.7.2

Additional Information

it works in this way

== render(partial: "portal/_nav.slang", path: "src/views/layouts/")

bug discussion help-wanted

Most helpful comment

This isn't technically a bug but it might be a good place to discuss expected behavior.

Currently if there are more than 2 parts in the path it will assume the root is your project root instead of src/views.

For instance this would work: render(partial: "src/views/layouts/tmp/_nav.slang") as would render(partial: "specs/samples/views/layouts/tmp/_nav.slang")

render(partial: "layouts/_nav.slang") works because there are only 2 parts.

It might be better to only use the path: option to set other paths instead of defaulting to that for longer path names.

This would be as simple as getting rid of this conditional in render.cr and making sure the tests still pass.

    private macro render_template(filename, path = "src/views")
      {% if filename.id.split("/").size > 2 %}
        Kilt.render("{{filename.id}}")
      {% else %}
        Kilt.render("#{{{path}}}/{{filename.id}}")
      {% end %}
    end

All 5 comments

Hi @jaysneg Thank for report this issue :+1:

Can you share us the error output using a gist? :sweat_smile:

This isn't technically a bug but it might be a good place to discuss expected behavior.

Currently if there are more than 2 parts in the path it will assume the root is your project root instead of src/views.

For instance this would work: render(partial: "src/views/layouts/tmp/_nav.slang") as would render(partial: "specs/samples/views/layouts/tmp/_nav.slang")

render(partial: "layouts/_nav.slang") works because there are only 2 parts.

It might be better to only use the path: option to set other paths instead of defaulting to that for longer path names.

This would be as simple as getting rid of this conditional in render.cr and making sure the tests still pass.

    private macro render_template(filename, path = "src/views")
      {% if filename.id.split("/").size > 2 %}
        Kilt.render("{{filename.id}}")
      {% else %}
        Kilt.render("#{{{path}}}/{{filename.id}}")
      {% end %}
    end

I could probably find time to work on that tonight if desired.

Looks like this has been fixed. Should we close it?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZeroPointEnergy picture ZeroPointEnergy  路  4Comments

yorci picture yorci  路  6Comments

blankoworld picture blankoworld  路  7Comments

conradwt picture conradwt  路  3Comments

eliasjpr picture eliasjpr  路  6Comments