[attaching image] [image: Inline image 1]
On Thu, Aug 13, 2015 at 11:04 AM, Sajith Ariyarathna <[email protected]> wrote: > Hi Manu, > > Please find my comments inline. > > -1 *ifCond* and *selectIf* > > I agree with your view. Since Mustache and Handlebars follow the *logic-less > template* approach, Caramel should also follow it. > > However there are some circumstances where you have to put some logic in > the template. For example, in [1] we have used selectIf helper to > determine the proper CSS class for some action buttons. Before introducing > selectIf helper, these CSS classes were hard-coded in this [2] .js file > (which is in the server-side). Hard-coding CSS classes is acceptable in > HTML templates and client-side JavaScripts, but not for other server-side > .js or .jsg files. That's why we introduced the selectIf helper. > > +1 for *for* >> > The {{index}} expression has been introduced to the {{#each}} block > helper in Handlebars 3.0.3 version. However startIndex, endIndex and jump > optional > parameters of the proposed for helper can be helpful. For example, > displaying only certain number of items based on a user input (see below > image). So, adding for helper will be helpful. > [image: Inline image 1] > > > [1] > https://github.com/sajithar/carbon-appmgt/blob/047b7831886f50f6e656ca9d56739d08003c7240/features/appmgt/org.wso2.carbon.appmgt.publisher.feature/src/main/resources/publisher/themes/mobileapp/partials/list-assets-row.hbs#L50 > [2] > https://github.com/sajithar/carbon-appmgt/blob/2d362df789eadc1b67e0edf41209380aa82bf7c1/features/appmgt/org.wso2.carbon.appmgt.publisher.feature/src/main/resources/publisher/themes/mobileapp/renderers/controllers/assets_router.js#L39 > > Thanks. > > > On Wed, Aug 12, 2015 at 6:40 PM, Manuranga Perera <[email protected]> wrote: > >> -1 *ifCond* and *selectIf* >> the reason we have separate *logic-less* temperating is to remove logic >> out of ui representation. this helper defeats whole purpose of having >> handlebars. >> different people have different opinions on this, see the discussion on >> https://github.com/wycats/handlebars.js/issues/616 . I personally don't >> like putting it in templates. >> >> It is better to do the necessary logic in the js/jag file and use the >> built in Helpers. is there any reason to not to do it this way? >> >> +1 for *for* >> but think it's there in new version anyway. is this one any different? if >> not we should just update to new Handlebars instead. >> >> On Wed, Aug 12, 2015 at 3:28 PM, Sajith Ariyarathna <[email protected]> >> wrote: >> >>> Hi All, >>> >>> For AppM we have implemented few custom Handlebars helpers [1]. Since >>> they are very helpful, we like to suggest them to add to the Caramel >>> framework. We suggest following 03 helpers. >>> >>> *ifCond* >>> >>> Conditional if block which can be used with a single logical expression. >>> ifCond helper supports ==, !=, ===, !==, <, <=, >, >=, &&, || and typeof >>> operators. >>> (see [2]) >>> >>> *for* >>> >>> Iterates over an array and iteration manner can be customized. Also, >>> index of the current iteration can be access as {{index}}. (see [3]) >>> >>> *selectIf* >>> >>> For the given value, outputs the result based on the specified >>> 'value-result' map. Very similar to the switch-case clause. (see [4]) >>> >>> >>> Thanks. >>> >>> [1] >>> https://github.com/wso2/carbon-appmgt/blob/master/features/appmgt/org.wso2.carbon.appmgt.publisher.feature/src/main/resources/publisher/themes/mobileapp/js/lib/handlebars/custom.handlebars.helpers.js >>> [2] >>> https://github.com/wso2/carbon-appmgt/blob/master/features/appmgt/org.wso2.carbon.appmgt.publisher.feature/src/main/resources/publisher/themes/mobileapp/js/lib/handlebars/custom.handlebars.helpers.js#L92 >>> [3] >>> https://github.com/wso2/carbon-appmgt/blob/master/features/appmgt/org.wso2.carbon.appmgt.publisher.feature/src/main/resources/publisher/themes/mobileapp/js/lib/handlebars/custom.handlebars.helpers.js#L143 >>> [4] >>> https://github.com/wso2/carbon-appmgt/blob/master/features/appmgt/org.wso2.carbon.appmgt.publisher.feature/src/main/resources/publisher/themes/mobileapp/js/lib/handlebars/custom.handlebars.helpers.js#L250 >>> >>> -- >>> Sajith Ariyarathna >>> Software Engineer; WSO2, Inc.; http://wso2.com/ >>> mobile: +94 77 6602284, +94 71 3951048 >>> >> >> >> >> -- >> With regards, >> *Manu*ranga Perera. >> >> phone : 071 7 70 20 50 >> mail : [email protected] >> > > > > -- > Sajith Ariyarathna > Software Engineer; WSO2, Inc.; http://wso2.com/ > mobile: +94 77 6602284, +94 71 3951048 > -- Sajith Ariyarathna Software Engineer; WSO2, Inc.; http://wso2.com/ mobile: +94 77 6602284, +94 71 3951048
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
