Hi Dakshika,
Thanks you for the response. I was managed to do this by writing a custom
helper to check whether the tenant is the super tenant.
Handlebars.registerHelper('isSuperTenant', function (action, options) {
if (caramel.meta().session.get("TENANT_ID") != undefined) {
if (caramel.meta().session.get("TENANT_ID") == -1234) {
return true;
}
}
return "";
});
AFAIU the problem here was with the ifCond helper. This issue came up when
comparing two integer values using ifCond. For String comparisons it worked
fine.
Thanks.
On Tue, Sep 15, 2015 at 3:09 PM, Dakshika Jayathilaka <[email protected]>
wrote:
> You can write custom helper and can load using theme.js.
>
> I have find one related issue[1] on handlbarjs. can you verify our
> handlebar version contain this fix.
>
> [1]
> https://github.com/wycats/handlebars.js/commit/75a4f0d9317709e00f5c84b6b9d8cc4241f26d84
>
> Regards,
>
> *Dakshika Jayathilaka*
> PMC Member & Committer of Apache Stratos
> Senior Software Engineer
> WSO2, Inc.
> lean.enterprise.middleware
> 0771100911
>
> On Tue, Sep 15, 2015 at 3:03 PM, Dinithi De Silva <[email protected]>
> wrote:
>
>> After discussing with Jerad, I have tried adding console logs to check
>> the type of the variable.
>>
>> var test = {{tenantID}}
>> console.log(typeof test);
>>
>> This gave the type as number.
>>
>> And then when I print the following, the result was true.
>>
>> console.log(test==1);
>>
>> The issue might be the ifCond registerHelper is not working with the
>> type number.
>>
>> Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
>> switch (operator) {
>> case '!=':
>> return (v1 != v2) ? options.fn(this) : options.inverse(this);
>> case '==':
>> return (v1 == v2) ? options.fn(this) : options.inverse(this);
>> case '===':
>> return (v1 === v2) ? options.fn(this) : options.inverse(this);
>> case '<':
>> return (v1 < v2) ? options.fn(this) : options.inverse(this);
>> case '<=':
>> return (v1 <= v2) ? options.fn(this) : options.inverse(this);
>> case '>':
>> return (v1 > v2) ? options.fn(this) : options.inverse(this);
>> case '>=':
>> return (v1 >= v2) ? options.fn(this) : options.inverse(this);
>> default:
>> return options.inverse(this);
>> }
>> });
>>
>>
>>
>> On Tue, Sep 15, 2015 at 2:04 PM, Dinithi De Silva <[email protected]>
>> wrote:
>>
>>> Hi Dakshika,
>>>
>>> I have tried out using "===" but it still gives the same result.
>>>
>>> Thanks.
>>>
>>> On Tue, Sep 15, 2015 at 1:50 PM, Dakshika Jayathilaka <[email protected]
>>> > wrote:
>>>
>>>> Hi,
>>>>
>>>> Try with "==="
>>>>
>>>> Regards,
>>>>
>>>> *Dakshika Jayathilaka*
>>>> PMC Member & Committer of Apache Stratos
>>>> Senior Software Engineer
>>>> WSO2, Inc.
>>>> lean.enterprise.middleware
>>>> 0771100911
>>>>
>>>> On Tue, Sep 15, 2015 at 1:31 PM, Dinithi De Silva <[email protected]>
>>>> wrote:
>>>>
>>>>> Hi Dakshika / Jerad,
>>>>>
>>>>> I am trying to retrieve the tenantId stored in a session variable into
>>>>> handlebars js file. The variable "teananID" has the value of the tenant id
>>>>> (Ex: -1234) but when comparing it with -1234 or any other integer the
>>>>> condition is always false.
>>>>>
>>>>> Please find the piece of code in my handlebar js file below.
>>>>>
>>>>> {{#ifCond tenantID "==" -1234}}
>>>>> <p>Test1</p>
>>>>> {{else}}
>>>>> <p>Test2</p>
>>>>> {{/ifCond}}
>>>>>
>>>>>
>>>>> Please note that I have tried printing the variable using console.log
>>>>> and it gave the value -1234. And also we can compare two strings using the
>>>>> same way without any issue.
>>>>>
>>>>> What could be the missing part in the condition to always become false?
>>>>>
>>>>> Thanks.
>>>>> --
>>>>> *Dinithi De Silva*
>>>>> Associate Software Engineer, WSO2 Inc.
>>>>> m:+94716667655 | e:[email protected] | w: www.wso2.com
>>>>> | a: #20, Palm Grove, Colombo 03
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> *Dinithi De Silva*
>>> Associate Software Engineer, WSO2 Inc.
>>> m:+94716667655 | e:[email protected] | w: www.wso2.com
>>> | a: #20, Palm Grove, Colombo 03
>>>
>>
>>
>>
>> --
>> *Dinithi De Silva*
>> Associate Software Engineer, WSO2 Inc.
>> m:+94716667655 | e:[email protected] | w: www.wso2.com
>> | a: #20, Palm Grove, Colombo 03
>>
>
>
--
*Dinithi De Silva*
Associate Software Engineer, WSO2 Inc.
m:+94716667655 | e:[email protected] | w: www.wso2.com
| a: #20, Palm Grove, Colombo 03
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev