danharper / Handlebars-Helpers

A small collection of useful helpers for Handlebars.js
Do What The F*ck You Want To Public License
274 stars 55 forks source link

Handlers lose model depth #2

Closed sameersegal closed 12 years ago

sameersegal commented 12 years ago

Hi, thanks for this extension. I have a problem using my template code along with your handler:

{{#each model._revs_info}}
{{debug ../model}}
{{#if_eq status compare="available"}}
{{debug ../model}}
{{rev}} {{/if_eq}}
{{/each}}

The first {{debug ../model}} statement works perfectly but the second doesn't. {{debug}} definition: http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/

I am sure that I am missing something basic. Thanks for your help in advance.

Best, Sameer

danharper commented 12 years ago

Are you using the latest version of the library? This sounds like an issue I fixed a while ago. On Jul 19, 2012 2:06 PM, "Sameer Segal" < reply@reply.github.com> wrote:

Hi, thanks for this extension. I have a problem using my template code along with your handler:

{{#each model._revs_info}} {{debug ../model}} {{#if_eq status compare="available"}} {{debug ../model}} {{rev}} {{/if_eq}} {{/each}}

The first {{debug ../model}} statement works perfectly but the second doesn't. {{debug}} definition: http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/

I am sure that I am missing something basic. Thanks for your help in advance.

Best, Sameer


Reply to this email directly or view it on GitHub: https://github.com/danharper/Handlebars-Helpers/issues/2

sameersegal commented 12 years ago

By library you mean handlebar or do you mean your helper functions? I copied your if_eq handler into my couchapp (which I am sure is the latest)

danharper commented 12 years ago

Yes, ensure my helper function is the up to date version. The old version didn't use the correct context inside the block. On Jul 19, 2012 6:45 PM, "Sameer Segal" < reply@reply.github.com> wrote:

sameersegal commented 12 years ago

Yes, the helper function are the latest - any pointers on how to solve this?

danharper commented 12 years ago

Handlebars' own if block does the same thing: http://jsfiddle.net/wBSsW/1/ It's a scope issue.

sameersegal commented 12 years ago

Thanks - I guess this can't be fixed? I decided to change my code and handle the logic in javascript and simplify the template.

On Fri, Jul 20, 2012 at 10:06 PM, Dan Harper < reply@reply.github.com

wrote:

Handlebars' own if block does the same thing: http://jsfiddle.net/wBSsW/1/ It's a scope issue.


Reply to this email directly or view it on GitHub:

https://github.com/danharper/Handlebars-Helpers/issues/2#issuecomment-7134814

sameersegal commented 12 years ago

Hi Dan, I had posted this as a question on StackOverflow - take a look at this link: http://stackoverflow.com/questions/11562612/handlebar-context-lost-after-passing-handler/11591735#11591735

I guess it seems to be working! Not sure what I was doing wrong

Best, Sameer

On Sat, Jul 21, 2012 at 10:13 AM, Sameer Segal sameer@artoo.in wrote:

Thanks - I guess this can't be fixed? I decided to change my code and handle the logic in javascript and simplify the template.

On Fri, Jul 20, 2012 at 10:06 PM, Dan Harper < reply@reply.github.com

wrote:

Handlebars' own if block does the same thing: http://jsfiddle.net/wBSsW/1/ It's a scope issue.


Reply to this email directly or view it on GitHub:

https://github.com/danharper/Handlebars-Helpers/issues/2#issuecomment-7134814

danharper commented 12 years ago

Hm, I didn't know you could double up ../ to reach a grandparent scope.

Yeah, the issue is that {{#each ..}} puts you into a new child scope. Then {{#if_eq ..}} does too.

sameersegal commented 11 years ago

Artoo : Technology to the Rescue

http://us4.campaign-archive1.com/?u=2f72a9870fd6bdb36ba19ed59&id=1e52f7164b&e=88259db69f Hello from Artoo,

We put two posters up on our wall this summer: “It Just Works” and “Care”. The biggest compliment that someone can give to a technology product is “it just works” (a phrase Steve Jobs said often). And, over the last two years, we’ve learned that what our clients like the most about us is the “care” with which we create solutions for them – taking into consideration the perspectives of both field agents and senior managers, and also learning what we can from industry best practices in both technology and development.

We’d like to share with you what’s been happening at Artoo lately:

With all these changes, it sometimes feels as if Artoo is coming of age.

Cheers, Sameer

\ Kavita Nehemiah,

Rainmaker

Kavita’s strong belief that business strategies and market based approaches can be used effectively in solving social problems, inspired her to join Artoo. Prior to Artoo, Kavita worked with Ujjivan Financial Services, where her experience spanned different functions, including credit and risk analysis, market research and product development. She has also worked in a consulting capacity with Rent-to-Own Africa (a micro-asset leasing company based in Lusaka, Zambia), VisionSpring (previously Scojo Foundation, based in New York) and as a summer intern with Elevar Equity. Kavita holds an undergraduate degree in Economics (Hons.) from St. Stephens College, New Delhi and an MBA from Cornell University.

\ Patrick Keating,

IDEX Fellow

Patrick graduated from the University of Virginia in May 2012 with a degree in Finance, Economics, and International Business. He has worked with an agricultural cooperative in Panama, studied microfinance and social enterprise in Bangladesh, and consulted for an American impact investing firm. He joins Artoo as part of the IDEX Fellowship in Social Enterprise, a 10 month program matching recent graduates with India’s top social enterprises. At Artoo, he aims to utilize his business skills to help the company further expand its social impact. Friend on Facebook (https://www.facebook.com/artootrills) Follow on Twitter (https://twitter.com/artootrills) Forward to a Friend (http://us4.forward-to-friend1.com/forward?u=2f72a9870fd6bdb36ba19ed59&id=1e52f7164b&e=88259db69f)

\ Artoo's New Website

Uttam has worked really hard to create a website that showcases the latest and the greatest version of our product through videos and screencasts. Here it is (https://www.artoo.in) !

\ Outlook Business

Artoo was featured in Outlook Business magazine's Independence Day special edition on Social Entrepreneurs. Here's the article (http://business.outlookindia.com/article.aspx?282037#4) .

\ YourStory TV

Sameer on YourStory TV talking about Artoo's motivations and challenges as a technology startup working in the social sector. Here's the video (http://yourstory.in/2012/09/how-do-you-sell-a-product-to-people-who-dont-know-what-they-want-sameer-segal-artoo/) .

\ New from Suratkal

We went to NITK Suratkal, Sameer's alma mater, for placements and received a whopping 251 applications from which we're happy to announce that we've chosen Rahul Kumar to join us full time when he graduates in May. We've gladly offered internships to Vishal Daga, Shashi Gowda, and Chandramouli Sharma too.

\ We're Hiring!

We are looking for JavaScript Engineers who are passionate about creating a social impact.

Engineer with a Backbone (https://artoo.in/portal/careers#Engineer-with-a-Backbone) Engineer at the Node (https://artoo.in/portal/careers#Engineer-at-the-Node)

Copyright © 2012 Artoo IT Solutions, All rights reserved. You are receiving this email because you are a friend of Artoo. Our mailing address is: 2630, 27th Main, 1st Sector, HSR Layout, Bangalore - 560102 Email Marketing Powered by MailChimp http://www.mailchimp.com/monkey-rewards/?utm_source=freemium_newsletter&utm_medium=email&utm_campaign=monkey_rewards&aid=2f72a9870fd6bdb36ba19ed59&afl=1 * follow on Twitter (https://twitter.com/artootrills) * friend on Facebook (https://www.facebook.com/artootrills) * forward to a friend (http://us4.forward-to-friend1.com/forward?u=2f72a9870fd6bdb36ba19ed59&id=1e52f7164b&e=88259db69f) * unsubscribe from this list (http://artoo.us4.list-manage1.com/unsubscribe?u=2f72a9870fd6bdb36ba19ed59&id=9dca5f5c0e&e=88259db69f&c=1e52f7164b) \ update subscription preferences (http://artoo.us4.list-manage.com/profile?u=2f72a9870fd6bdb36ba19ed59&id=9dca5f5c0e&e=88259db69f)