Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
30 views

In typescript, I want to assign a number variable to a string variable that only accepts numerical strings. I tried the following: const x: number = 0; const y: `${number}` = x.toString(); But ...
Semanual's user avatar
  • 113
0 votes
3 answers
50 views

Is it possible to interpolate a template string using key/values from a object in JavaScript, like string substitution in Python: data = {"age": 18, "name": "John"} "...
FaniX's user avatar
  • 440
0 votes
1 answer
101 views

I'm trying to add JSX elements like <a>, <p> and else to an array of objects in a template string, this project has a portfolio.jsx file that holds the array, another file called Projects....
Fred's user avatar
  • 13
1 vote
1 answer
4k views

I have this type: export type ICfnOutput = { ENDPOINTS: { [key in `${keyof typeof MSERVICES}_ENDPOINT`]: string }, USER_POOL_CLIENT_ID: string, amplifyClientUrl: string, ...
Woohaik's user avatar
  • 1,354
0 votes
1 answer
544 views

Is it possible to make the click event working for template strings like this? const htmlTemplate = ` <div> <div> <textarea df-template></textarea> <button (...
brb's user avatar
  • 17
1 vote
1 answer
954 views

I'm using plop for code generation of some TypeScript files. This is not using HTML at all. Under the hood plop uses Handlebars for it's templating. One of my templates generates a series of new ...
stetson's user avatar
  • 145
0 votes
1 answer
1k views

I have this object totalData which I am destructuring to add on a new object value. I understand I am able to define new object properties using template strings (as shown below) but how can I use ...
Brian Mason's user avatar
0 votes
1 answer
156 views

👉The original file is docx format, which has multiple tables, but there may be format problems, so it cannot be read by python-docx. ✔️ 1.Solution by hand: solve the question by click [save as ....]...
3 ert's user avatar
  • 1
0 votes
1 answer
331 views

I have a string variable containing a control character (newline). I want to output that variable but with the control character as its literal representation and not interpreted: console.log(`Using &...
Kai Roesner's user avatar
0 votes
0 answers
100 views

Please be patience, my english is not that good. I am trying to create a for loop to push for each image imported, an object with different values. I want to avoid just setting all the objects i want ...
Juan Manuel's user avatar
0 votes
1 answer
331 views

I have some JSON that looks a little like this: component.json [ { "template": "<div class="${layout} ${border}"></div>" }, { "layout": &...
daggett's user avatar
  • 279
0 votes
1 answer
489 views

I want to use a template string in a mongoose update query using typescript. The field I want to update is a Map called messages with string keys and array values of type Message. So something like ...
sethgypt's user avatar
3 votes
4 answers
134 views

My teacher in JavaScript gave me an assignment to master functions. I tried to solve the assignment which requires me to make the output like the second code: function showDetails(name = "unknown&...
MrKing09's user avatar
1 vote
0 answers
29 views

I have 11 buttons with their own class, as well as all 11 share the class .theme-color. I am trying to have it change to the background color on the button class. My idea was to get the class into the ...
JacobVerDugt's user avatar
0 votes
0 answers
29 views

I try to use the npm qrcode API with express. When the user enters an address into a form, the QR-Code should be displayed on the website. I searched for a long time, but can't figure it out, since I ...
TobiG's user avatar
  • 3
1 vote
1 answer
87 views

I am working on a project and would like to use prodConfig or draftConfig according to few conditions. I am using Hasura and getting 2 different JSON responses with only 1 key different in the ...
Anoop V's user avatar
  • 231
0 votes
1 answer
286 views

somewhere from the API data I am getting normal string like, “Hi ${person[0].name}” now this string I am converting into template string and getting replace its variables from array of object. Here is ...
aToz's user avatar
  • 3
3 votes
1 answer
2k views

Just followed the twin.macro tutorial to set it up with next.js, styled-components & typescript. Followed everything in a newly setup project, but I'm getting this error: ./components/...
antonwilhelm's user avatar
  • 7,855
0 votes
2 answers
646 views

hello friends I got a hard one and I'm a bit in a pickle in my blackjack game I create images(of the cards) and the values come from the .PNG name from a list in an object. what I want to do is be ...
Pierre-Yves Roy's user avatar
0 votes
1 answer
703 views

Resultant Response in Messenger. But I need to bold username, phone-number, etc. I am new in web development. I also tried \x3Cb>I am Bold\x3C/b>" but didn't work for me. How can I add HTML ...
Junaid Ahmed's user avatar
1 vote
1 answer
2k views

I was trying to implement ngx-translate in one of the recently completed angular projects. In the project we have a component that renders HTML files inside a certain div through innerHTML. Now as I ...
Atul Stha's user avatar
  • 1,534
0 votes
2 answers
2k views

I have tables that I am displaying using dangerous HTML in reacting hooks Live Demo : live demo code sand box Data looks like this export const json = [ { template: ` <div ref={tableRef} ...
The Dead Man's user avatar
  • 5,604
0 votes
1 answer
1k views

I have some html that I converted into a template string and getting the above error when I check the checkbox, I know it has to do with the ${currentRow}, just not sure why its acting this way ...
Chris's user avatar
  • 3,181
1 vote
1 answer
481 views

I am trying to set the href attribute of an <a>-Tag inside a template string but it does not work. function createLink(object) { return `<a href="${object.DetailActionUri}">...
Ens's user avatar
  • 95
1 vote
0 answers
45 views

On this page there is the following code snippet (which can also be found here), demonstrating some use of a template string. The only explanation or context is the comment at the start, which makes ...
Ger's user avatar
  • 958
0 votes
0 answers
79 views

Let's say i have the following union: type T = "a.success" | "a.failure" | "b.success" | "c"; and I want to get a union of all strings that match two patterns ...
Michal Kurz's user avatar
  • 2,206
0 votes
1 answer
536 views

Is it possible to create a variable using template strings? Here is a simple example of what I want to achieve: let times, hours="fullTime"; if (hours === "fullTime") { ...
Ruairidh Grass's user avatar
0 votes
1 answer
50 views

I have smth like this const activeLang = 'pl' const uniqueCategories = products.map((product) => { return product.category_pl }) How do I make this the same but with using template ...
Filippo854's user avatar
1 vote
1 answer
419 views

To get some html to render nicely inside a textarea, I have to make my code-indentation look ugly; What's the proper way to write my template literal, without resorting to bad indentation?
joedotnot's user avatar
  • 5,193
0 votes
2 answers
60 views

I`m on the Javascript30 #1 now, and I`ve been wondering about a small stuff... This code below worked. const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`); But, this code ...
pop's user avatar
  • 139
9 votes
1 answer
9k views

I am trying to make a graphql request using the npm package graphql-request. I am discovering the use of template literals. async getCandidate(userId: number) { const query = gql` ...
A Mehmeto's user avatar
  • 2,067
0 votes
0 answers
604 views

I am trying to use Link of react router inside a template string with no success. i tried also to wrap the tag with ${} but that doesnt work either. does anyone know how can i make it work? const ...
Aviv Cohen's user avatar
-1 votes
2 answers
100 views

I have a problem with the template literals JS. I get user data and an SMS template from a MySQL table. // User fields let name = data.info.name; // Chingis let start_datetime = data.info....
Chingis Khuurak's user avatar
0 votes
1 answer
293 views

I have a fetch() function to collect data from Skyscanner API. It works fine until I use template literals. This results in getting error 400. public departureAPI = "WAW-sky"; fetch( &...
JoseTurron's user avatar
0 votes
0 answers
26 views

I have this object: let user = { name: undefined, age: undefined, city: undefined, } and these arrays props = ["name", "age", "city"]; values = ["alan", 90, "london"]; and i want to do ...
Emi Jerochim's user avatar
0 votes
1 answer
852 views

I have this code in my ty file: onSubmit(form: NgForm){ console.log('Executado') let dados = ` name: ${form.value.name}, email: ${form.value.email}, specialty: ${form.value.specialty}, ...
Andrew Almeida's user avatar
-1 votes
2 answers
1k views

I've got a functional component const Paragraph = forwardRef((ref: any) => { return ( <div> <p dangerouslySetInnerHTML={{ __html: props.text }}></p> </div> ...
ekclone's user avatar
  • 1,052
0 votes
2 answers
53 views

I was looking at some javascript code and noticed a line using the template string backticks: a=`${a}` However, this does not seem to have any effect to me as the variable a contains a string. Is ...
Octetz's user avatar
  • 301
0 votes
1 answer
84 views

I have a config file that has different URLs for different environments. I am using the object key for base url from the given object. const configDev = { API: { url: 'http://api.domain....
Jappreet's user avatar
  • 377
0 votes
1 answer
299 views

Symbol.toPrimitive method, invoked within tagged template literal loses access to the closure. To reproduce, simply paste the provided code snippet in dev console, run it with and without tag-...
user avatar
0 votes
3 answers
151 views

I see in some places, to get the value of title from props, we use {`${props.title} `} while in some other places, we use it {props.title} What is the difference?
hatellla's user avatar
  • 5,212
1 vote
2 answers
6k views

I'm trying to use the sql template strings npm package to use template literals in my SQL queries securely, but I keep getting an error that states that there is a problem with the sql syntax. When I ...
StephC's user avatar
  • 13
0 votes
1 answer
366 views

In my project I am using a lot of JavaScript template string. After webpack compilation that is resulting in newlines, tabs and white spaces. How can I remove it with regex or any DOM API like ...
Rajkeshwar Prasad's user avatar
6 votes
0 answers
512 views

I am working on a system that generates JavaScript, and I would like to minimize the amount of escaping that needs to be done for string literals. My current approach is to use the String.raw template ...
Mihai Parparita's user avatar
1 vote
4 answers
4k views

I am getting issue while displaying my table data inside tbody, in my javascript i am getting result object and i am using template literals inside javascript file Here's my code: for (i = 0; i < ...
Ikram Khizer's user avatar
2 votes
1 answer
62 views

I'm trying to write a simple Id monad to play around with and learn. Here is what I've written: const util = require('util'); const Id = x => ({ [util.inspect.custom]: () => `Id(${x})`, ...
J. Hesters's user avatar
6 votes
2 answers
9k views

I am creating a bash command: const k = cp.spawn('bash'); k.stdin.end(` alias ssh='ssh "${SSH_ARGS[@]}"' `); but of course, I have to escape it. I assume the best way to escape it, is using: `...
Alexander Mills's user avatar
0 votes
2 answers
2k views

I have a function that returns a component that depends on the pathname of the window. getComponentByPathname = (pathname) => { switch(patname){ case "/view1": return <...
Hctor Aldair Aguilar Hernndez's user avatar
0 votes
1 answer
902 views

I can't figure out how to implement a greater then formula within a template string to return a boolean value (see code). const age = 47; // simplified for question let html; html = `<ul> ...
Plague3D's user avatar
-1 votes
1 answer
103 views

I need to create some substrings using the template string. I try to use this code but I have some problem about the auto filling of the template. Object.keys(optionsParams).forEach(function (...
Safari's user avatar
  • 12k