question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v2] JSX with vhtml.js and async templating

See original GitHub issue

This is a enhancement

Actually I need something like this:

component: {
  asyncTemplate: (render) => {
    request(...)
       .then(html => {
         render(html)
       })
  }
}

There any way to exists this method?

Other idea is allow to return dom elements in .render() or/and .template() methods like this:

component: {
  render: () => {
    return domElement
  },
  // or
  render: domElement
}

This would be awesome because allows developers to uses libs like jsx-dom or vhtml and do something beautiful like this:

component: {
  render: () => {
    return (
      <div class="page">
        <div class="page-content">
          {items.map(item, =>
            <div class="whatever"></div>
          )}
        </div>
      </div>
    )
  },
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
nolimits4webcommented, Sep 22, 2017

Agree, there probably could be some kind of babel jsx plugin to understand custom attributes. I see Vue js have their own babel jsx plugin.

But anyway, if you are going to use babel, you can just use es-next templates to achieve almost the same:

...
render() {
  const self = this;
  const { items } = self;
  return `
    <div class="foo">
      <h1>Hi!</h1>
      <p @click="test">Here is a list of ${items.length} items:</p>
      <ul>
        ${items.map(item => `
          <li>${item}</li>
        `).join('')}
      </ul>
    </div>
  `;
},
data() {
  return {
    items: ['one', 'two', 'three'],
  }
},
...
0reactions
nolimits4webcommented, Mar 13, 2018

Issue is closed because of outdated, irrelevant or not actual

If this issue is still actual and reproducible for latest version of Framework7, please create new issue and fill the issue template correctly:

  • Clearly describe the issue including steps to reproduce when it is a bug.
  • Make sure you fill in the earliest version that you know has the issue.
  • Provide live link or JSFiddle/Codepen or website with issue
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using serverside HTML-templates with ReactJS - Stack Overflow
You need to convert JSX to JS (usually done when building your ... Then of course, there's the issue of loading code asynchronously....
Read more >
Render Functions & JSX - Vue.js
Render Functions & JSX. Basics. Vue recommends using templates to build your HTML in the vast majority of ... An HTML tag name,...
Read more >
How To Create React Elements with JSX - DigitalOcean
JSX is an abstraction that allows you to write HTML-like syntax in your JavaScript ... JSX is the templating language of React elements, ......
Read more >
A JSX based html templating engine for browsers or Node ...
A JSX based html templating engine for browsers or Node environments ... components asynchronous and send async requests from within them.
Read more >
Iterate Through a JSON Response in JSX Render for React
1async function getRandomUsers() { 2 const res = await ... 3 const data = await res.json(); 4 return data.results; 5}. js.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found