rc-source-loader

1.0.2 • Public • Published

rc-source-loader

This package can directly read the source code of the file. Without any conversion

demo.js

export default function generateErrorTemplate(err) {
  const strToHtml = (str) =>
    (str || '')
      .replace(/&/g, '&')
      .replace(/</g, '<')
      .replace(/>/g, '>')
      .replace(/"/g, '')
      .replace(/'/g, "'")
      .replace(/\[(\d+)m/g, '')
      .replace(/ /g, ' ')
      .replace(/\n/g, '<br />');
  const template = `
          <!DOCTYPE html> 
          <html>
          <head>
          </head>
          <body>
            <div>
              ${strToHtml(err.toString()) || ''}
            </div>
          </body>
          </html>`;
  return template;
}

Use

import demo from 'rrc-source-loader!./demo.js';
// Directly output the contents of this js
console.log(demo);

Readme

Keywords

none

Package Sidebar

Install

npm i rc-source-loader

Weekly Downloads

645

Version

1.0.2

License

MIT

Unpacked Size

3.96 kB

Total Files

4

Last publish

Collaborators

  • chenshuai2144