Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numeric 0 passed as @!component() agrument becomes nothing in the component. Passing it as string goes fine. #83

Closed
WhereJuly opened this issue Nov 8, 2020 · 4 comments
Assignees
Labels
Type: Question Needs clarification

Comments

@WhereJuly
Copy link

WhereJuly commented Nov 8, 2020

Description

ACTUAL BEHAVIOUR

  1. I pass zero (in fact a $loop.index) into a component as follows and for a numeric 0 argument value I get the argument empty inside the component:
{{-- Calling the component --}}
<ul>
    @each(item in [
    {item: 'Item #:'},
    {item: 'Item #:'},
    {item: 'Item #:'},
    ])

    @!component('mycomponent', index = $loop.index)

    @endeach
</ul>

{{-- The component template --}}
<li>{{ index }}</li>


{{-- Outcome --}}
<li></li>
<li>1</li>
<li>2</li>
  1. If I cast numeric 0 to string before passing to the component it goes fine, showing 0 in the component:
{{-- Transform 0 to string at --}}
@!component('mycomponent', index = $loop.index + '')

{{-- Outcome --}}
<li>0</li>
<li>1</li>
<li>2</li>

Expected Behaviour

Probably passing numeric 0 to component should be kept as such within the component.

Though all in all the templating engine is just so great.

@WhereJuly WhereJuly changed the title Numeric zero as @!component() agrument passed becomes nothing in the component. Passing it as string goes fine. Numeric zero passed as @!component() agrument becomes nothing in the component. Passing it as string goes fine. Nov 8, 2020
@WhereJuly WhereJuly changed the title Numeric zero passed as @!component() agrument becomes nothing in the component. Passing it as string goes fine. Numeric 0 passed as @!component() agrument becomes nothing in the component. Passing it as string goes fine. Nov 8, 2020
@thetutlage
Copy link
Member

Which version of Edge are you using?

@thetutlage thetutlage self-assigned this Nov 8, 2020
@WhereJuly
Copy link
Author

WhereJuly commented Nov 8, 2020

@thetutlage Hi,

I am using it under AdonisJS "@adonisjs/framework": "^5.0.9" and I cannot see the Edge separtely in my package.json.

In node_modules/edge.js/package.json it says "version": "1.1.4".

@thetutlage thetutlage removed their assignment Dec 5, 2020
thetutlage added a commit that referenced this issue Dec 5, 2020
@thetutlage thetutlage self-assigned this Dec 5, 2020
@thetutlage thetutlage added the Type: Question Needs clarification label Dec 5, 2020
@thetutlage
Copy link
Member

Sorry for the late reply. I just added a test for same and it seems to be working fine for me

@WhereJuly
Copy link
Author

@thetutlage Thanks. I see. So far I have no time to check it again. I would close the issue but keep an eye on it. As soon as I approach another similar case I make another check and return here with what I find, if something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Needs clarification
Projects
None yet
Development

No branches or pull requests

2 participants