Hi Yasima,

I'll try that and see.

Thank you.

On Wed, Dec 6, 2017 at 2:34 PM, Yasima Dewmini <[email protected]> wrote:

> Hi Nipuni,
>
> Can you try as following without using Jquery? It worked for me.
>
> Handlebars.registerPartial("generateDoc", 
> document.getElementById("generateDoc").innerHTML);
>
> Refer [1] for more information.
>
> [1] https://stackoverflow.com/questions/25430864/how-to-use-
> handlebars-registerpartial-using-javascript
>
> Regards,
> Yasima.
>
> On Wed, Dec 6, 2017 at 9:30 AM, Nipuni Salgado <[email protected]> wrote:
>
>> Hi all,
>>
>> Currently, I'm working with the WSO2 TCC team on the project 'Automate
>> Reference Documentation for Configuration Files'.
>>
>> The implementation of the project is done by using the JavaScript
>> implementation of handlebars - handlebars.js [1].
>>
>> In my implementation the json object which need to be passed to the
>> handlebars partials is stored in a json file. What I need to do is read the
>> json object from that file and pass that object as the context to the
>> handlebars partials.
>>
>> I tried doing it as shown in the following code snippet,
>>
>> $.getJSON(path, function(json) {
>>     var source = $("#main").html();
>>     var template = Handlebars.compile(source);
>>     var context = json;
>>     Handlebars.registerPartial('generateDoc', $("#generateDoc").html());
>>     Handlebars.registerPartial('generateYamlDoc', 
>> $("#generateYamlDoc").html());
>>     var output = template(context);
>>     $("#content").html(output);
>>     });
>>
>>
>> But when I debug it gives an error, "Error: Attempting to register a
>> partial called "generateDoc" as undefined".
>>
>> Therefore, I need to know how to register a partial using handlebars.js
>> and how to pass a json object as the context to the registered partial.
>>
>> Appreciate your help on this matter.
>>
>> [1] - http://handlebarsjs.com/
>>
>> Thank you.
>>
>>
>> *Nipuni Salgado*
>>
>> *Trainee Software Engineer*
>>
>> *WSO2*
>>
>> Email: *[email protected] <[email protected]>*
>> Mobile: +94779973350 <+94%2077%20997%203350>
>> Web: *http://wso2.com <http://wso2.com>*
>>
>> <https://wso2.com/signature>
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> http://wso2.com/signatureYasima Dewmini
> Software Engineer, WSO2, Inc.
> Email: [email protected]
> Mobile: +94713117081 <+94%2071%20311%207081>
>



-- 

*Nipuni Salgado*

*Trainee Software Engineer*

*WSO2*

Email: *[email protected] <[email protected]>*
Mobile: +94779973350
Web: *http://wso2.com <http://wso2.com>*

<https://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to