Skip to content

How to escape backticks? #22

@anzuj

Description

@anzuj

I'm trying to showcase this code via prism:

 code: `this.reasons.push({
        id: i,
       name: `Reason-${i}`
      });`

and in template:
<prism language="js">{{ code}}</prism>

When compiling I get an error:

Failed to compile.
./src/components/Reasons/Reason-8.vue?vue&type=script&lang=js& (./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Reasons/Reason-8.vue?vue&type=script&lang=js&) 58:14
Module parse failed: Unexpected token (58:14)
File was processed with these loaders:
 * ./node_modules/cache-loader/dist/cjs.js
 * ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
    this.reasons.push({
       id: i,
        name: \`Reason-${i}\`
     });
    }

How can I overcome this problem and use template literals with Prism?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions