I
I
Isaac Clark2015-10-21 16:22:10
Handlebars
Isaac Clark, 2015-10-21 16:22:10

How to render Handlebars template in React.js in iFrame tag?

Hello, I'm getting an .hd template from the server and I want to parse it, then add it to an iFrame and render it in React. Here is the code:

getTemplate: function () {
    var template = Handlebars.compile(this.props.previewHtml.html),
          html = template(this.props.previewContext),
          iFrame = 'data:text/html,<html><body">' + html + '';

    return <iframe src={iFrame } />;
}

The problem is that the template is not rendering. What am I doing wrong, please tell me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2015-10-21
@OneFive

Try encrypting the data url in base64, you get something like data:text/html;base64,AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question