• HOME
    • PRODUCT
    • PRICING
    • ABOUT
    • COMMUNITY
    Menu
    • HOME
    • PRODUCT
    • PRICING
    • ABOUT
    • COMMUNITY
    Get in touch
    Get in touch
    Menu
    • HOME
    • PRODUCT
    • PRICING
    • ABOUT
    • COMMUNITY
    • Sign in
    • Start free trial
    • Get in touch
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags
    • Users
    • Groups
    • Documentation
      • Home
      • Read API
      • Write API
      • Plugin Development
    1. Home
    2. tryinteg
    T
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 3
    • Best 0
    • Controversial 0
    • Groups 0

    tryinteg

    @tryinteg

    0
    Reputation
    3
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    tryinteg Unfollow Follow

    Latest posts made by tryinteg

    • a question about syntax of benchpressjs

      I have a question about benchpressjs: say, I have an array, I want to skip the output for the first and second item in the array, here is my code:

                          *{{{ each localNews.topics }}}
                          {{{ if @index !="0" }}}
                          {{{ if @index !="1" }}}
                          <div>{@value}</div>
                          {{{ end }}}
                          {{{ end }}}
                          {{{ end }}}*
      

      but the code is not working, any ideas or suggestion? thanks in advance

      posted in NodeBB Development
      T
      tryinteg
    • RE: the issue of benchpressjs

      Thanks for the help and sorry if the "terrible" word hurts your feeling, I didn't mean to.

      @PitaJ said in the issue of benchpressjs:

      First off, calling their work "terrible" is a really bad strategy if you're trying to get help from someone. I'll still help, because I like being helpful, but please don't act this way in the future.

      #1. about Interpolation, benchpressjs does NOT allow to retrieve array by index, like this:
      <h1>{localNews.topics[0].title}</h1>

      If you're trying to just get a specific single element of an array, you just put the number as the property name, like so:

      <h1>{localNews.topics.0.title}</h1>
      

      I see this isn't documented, so I'll open an issue to document this behavior.

      #2, about helper function, I created one like this:
      Benchpress.registerHelper('getByIndexInArray', function (arrayData, i) {
      return arrayData[i];
      });

      and call this helper function like this:
      <h5>{getByIndexInArray(localNews.topics, 1)}</h5>

      But it seems like the index "i" can not be passed into the helper function, since in this helper function, I always got "i" as undefined.

      Your helper is correct, it's how you're calling it that's the issue. Benchpress doesn't have numeric literals, it only has string literals. Putting just 1 in there is telling Benchpress to look up the property "1" on the global object, and call the helper with that value (which is undefined in your case). Your helper will work if you call it like this instead:

      <h5>{getByIndexInArray(localNews.topics, "1")}</h5>
      

      I will also add a note to document this behavior in the paths and helper section.

      Issue is here: https://github.com/benchpressjs/benchpressjs/issues/89

      pitaj created this issue in benchpressjs/benchpressjs

      closed Document numeric property access and lack of numeric literals #89

      posted in NodeBB Development
      T
      tryinteg
    • the issue of benchpressjs

      I am working on benchpressjs and trying to customize NodeBB templates. I found some issues of benchpressjs.

      #1. about Interpolation, benchpressjs does NOT allow to retrieve array by index, like this:
      <h1>{localNews.topics[0].title}</h1>

      #2, about helper function, I created one like this:
      Benchpress.registerHelper('getByIndexInArray', function (arrayData, i) {
      return arrayData[i];
      });

      and call this helper function like this:
      <h5>{getByIndexInArray(localNews.topics, 1)}</h5>

      But it seems like the index "i" can not be passed into the helper function, since in this helper function, I always got "i" as undefined.

      it seems like benchpressjs is terrible template engine or maybe what I did is wrong? any suggestion/ideas?

      posted in NodeBB Development
      T
      tryinteg

    Get Started

    • Product
    • Pricing

    Resources

    • Demo Site
    • Answers
    • Docs
    • Bug Bounty

    Company

    • About
    • Blog
    • Contact
    Start Free Trial
    Github Facebook Instagram Twitter
    © 2014 – 2022 NodeBB, Inc. — Made in Canada.
    • Terms
    • Privacy
    • GDPR
    • DMCA
    • Contact
    Menu
    • Terms
    • Privacy
    • GDPR
    • DMCA
    • Contact