How to use the vue-inbrowser-compiler.isCodeVueSfc function in vue-inbrowser-compiler

To help you get started, we’ve selected a few vue-inbrowser-compiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vue-styleguidist / vuepress-plugin-live / markDownPlugin.js View on Github external
const getScript = code => {
      // script is at the beginning of a line after a return
      // In case we are loading a vue component as an example, extract script tag
      if (isCodeVueSfc(code)) {
        const parts = parseComponent(code);
        return parts && parts.script ? parts.script.content : "";
      }
      //else it could be the weird almost jsx of vue-styleguidist
      return code.split(/\n[\t ]*
github vue-styleguidist / vue-live / src / Preview.vue View on Github external
renderComponent(code) {
      let data = {};
      let style;
      try {
        const renderedComponent = compile(
          code,
          this.jsx
            ? { jsx: "__pragma__(h)", objectAssign: "__concatenate__" }
            : {}
        );
        style = renderedComponent.style;
        if (renderedComponent.script) {
          // if the compiled code contains a script it might be "just" a script
          // if so, change scheme used by editor
          this.$emit("detect-language", isCodeVueSfc(code) ? "vue" : "js");

          // compile and execute the script
          // it can be:
          // - a script setting up variables => we set up the data property of renderedComponent
          // - a `new Vue()` script that will return a full config object
          const script = renderedComponent.script;
          data =
            evalInContext(
              script,
              filepath => requireAtRuntime(this.requires, filepath),
              adaptCreateElement,
              concatenate
            ) || {};
        }
        if (renderedComponent.template) {
          // if this is a pure template or if we are in hybrid vsg mode,

vue-inbrowser-compiler

compile vue single file components right in your browser

MIT
Latest version published 1 year ago

Package Health Score

79 / 100
Full package analysis