Questions tagged [tagged-templates]

37 questions
0
votes
1 answer

How to get qql expression from String

I have a String variable with GraphQL query. I want to write function which will return this the gql tag. Could you help me to write it. For example: Input: let input = `query { employee { id surname } }`; Output: let output = gql`query { employee…
0
votes
1 answer

Tagged template to get rid of first new-line

I have a function like this: export default ({ subDomain }) => ` { mutation ${upperCase(subDomain)} { ${lowerCase(subDomain)} { ok } } } ` However it returns a string that starts with a new line. I don't want to…
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
0
votes
1 answer

Tagged template literals in styled-components with an optional additional parameter

Just trying to get my head around styled-components, specifically the suggestion in the docs which says you can set up media query templates like this: const breakpoint = (...args) => { return css` @media (min-width: 600px) { …
0
votes
0 answers

Interpolate variable inside tagged template

I'm using tagged templates to build a query with its params. function query (strings, ...args) { return { sql: strings.join('?'), params: args } } const storeId = '417-123'; const id = 10; const res = query`select * from…
Auré Km
  • 19
  • 1
0
votes
1 answer

How to report errors while parsing content in ES6 tagged templates?

I'm working with a friend on a small Javascript experiment, which involves a basic HTML parser, implemented as a simple state machine - you can see the code here. My question is regarding tagged template functions which involve any kind of parser,…
mindplay.dk
  • 7,085
  • 3
  • 44
  • 54
0
votes
1 answer

ES6: tagged templates for nested html tags

I'm newly learning JavaScript and experimenting its tagged template literals.

Handlebars? Tagged template literals? That is a question.

Above is HTML code. I want to achieve with below code the similar outcome but allow the…
sijane
  • 99
  • 6
-1
votes
2 answers

Error when trying to render a tagged string literal

I'm fetching some data from an API , then for each element returned I'm running this code: fetch("./apifiles.json").then((res) => res.json()).then((users) => { users.usuarios.forEach(e => { var div =…
1 2
3