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

Declare variable #26

Closed
alithestar2000 opened this issue Feb 21, 2018 · 6 comments
Closed

Declare variable #26

alithestar2000 opened this issue Feb 21, 2018 · 6 comments

Comments

@alithestar2000
Copy link

Hi Virk,

If this platform is wrong then I appologise in advance. Right now i am confused about how to declare a variable in edge.js. like say i want to declare a variable named "i" and then want to increment in a loop. how to do it?

@thetutlage
Copy link
Member

Can you please share some code?

@alithestar2000
Copy link
Author

alithestar2000 commented Feb 21, 2018

Here is a snippet from my code:
screen shot 2018-02-21 at 15 47 21

var i = 0;
@each(u in users_data)

{{i = i + 1}}
{{ u ? u.username: ''}}


<a class="btn btn-primary btn-sm" href='customer_friend_list?cid='+u.username> Friends


Remove


@endeach

@RomainLanz
Copy link
Member

Why you aren't using the $loop.index variable?

http://edge.adonisjs.com/docs/iteration#_loop_variable

@alithestar2000
Copy link
Author

alithestar2000 commented Feb 22, 2018

@RomainLanz thank you so much. it's a gr8 answer. I have now what i wanted.

Now just a private question. I was using Jade previously but some hurdles forced me to find some other template engine. Since I am myself a php developer and know laravel and now I just get a chance to work with node. My question is whether edge.js is a complete templating solution. My project is at the start. can i carry this big project with edge.js?

Thanks in advance.

@thetutlage
Copy link
Member

@alithestar2000 It depends on your definition of complete.

I believe by browsing the docs, you can get much of the idea on what all Edge supports and feel free to ask questions around it on the forum https://forum.adonisjs.com/

@alithestar2000
Copy link
Author

@thetutlage thank you. I feel now that you have strong belief in this so i can continue with this.

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

No branches or pull requests

3 participants