Skip to content

Template HTML is escaped, how do I fix it (straight javascript) #854

Answered by Haroenv
treeder asked this question in Q&A
Discussion options

You must be logged in to vote

you can use jsx as html is indeed escaped. For example: https://codesandbox.io/s/nostalgic-pasteur-mdsff?file=/app.js

        templates: {
          item({ item }) {
            // you can use jsx
            return (
              <div>
                <a href={`/things/${item.objectID}`}>{item.name}</a>
              </div>
            );
          },
          noResults() {
            // you can also use "h" directly:
            return h('div', {}, h('a', { href: '/' }, 'no results link'));
          },
        },
      },

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@treeder
Comment options

@Haroenv
Comment options

@treeder
Comment options

Answer selected by treeder
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants