├── .eslintrc.json ├── .gitignore ├── .npmrc ├── .prettierrc.json ├── LICENSE ├── README.md ├── bin ├── engines │ ├── pug.js │ └── vue.js └── index.js ├── package-lock.json └── package.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "es6": true, 5 | "node": true 6 | }, 7 | "parserOptions": { 8 | "ecmaVersion": 2018 9 | }, 10 | "extends": [ 11 | "eslint:recommended", 12 | "plugin:prettier/recommended" 13 | ], 14 | "plugins": [ 15 | "promise", 16 | "unicorn" 17 | ], 18 | "rules": { 19 | "dot-notation": [ 20 | "error" 21 | ], 22 | "eqeqeq": [ 23 | "error", 24 | "smart" 25 | ], 26 | "no-console": ["off"], 27 | "no-else-return": [ 28 | "error" 29 | ], 30 | "no-extra-bind": [ 31 | "error" 32 | ], 33 | "no-extra-label": [ 34 | "error" 35 | ], 36 | "no-implicit-coercion": [ 37 | "error", 38 | { 39 | "allow": [ 40 | "!!" 41 | ] 42 | } 43 | ], 44 | "strict": [ 45 | "error", 46 | "global" 47 | ], 48 | "linebreak-style": [ 49 | "error", 50 | "unix" 51 | ], 52 | "no-lonely-if": [ 53 | "error" 54 | ], 55 | "arrow-body-style": [ 56 | "error", 57 | "as-needed" 58 | ], 59 | "no-unused-vars": [ 60 | "error", 61 | { 62 | "args": "none" 63 | } 64 | ], 65 | "no-useless-computed-key": [ 66 | "error" 67 | ], 68 | "no-useless-rename": [ 69 | "error" 70 | ], 71 | "no-var": [ 72 | "error" 73 | ], 74 | "prefer-spread": [ 75 | "error" 76 | ], 77 | "prefer-template": [ 78 | "error" 79 | ], 80 | "prefer-const": [ 81 | "warn", 82 | { 83 | "destructuring": "all" 84 | } 85 | ], 86 | "no-empty-function": [ 87 | "error" 88 | ], 89 | "vars-on-top": [ 90 | "error" 91 | ], 92 | "unicorn/filename-case": [ 93 | "warn", 94 | { 95 | "case": "kebabCase" 96 | } 97 | ], 98 | "unicorn/throw-new-error": [ 99 | "error" 100 | ], 101 | "unicorn/no-array-instanceof": [ 102 | "error" 103 | ], 104 | "unicorn/no-new-buffer": [ 105 | "error" 106 | ], 107 | "unicorn/no-hex-escape": [ 108 | "error" 109 | ], 110 | "unicorn/prefer-starts-ends-with": [ 111 | "warn" 112 | ], 113 | "promise/catch-or-return": [ 114 | "error" 115 | ] 116 | } 117 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | .DS_Store 8 | 9 | # Runtime data 10 | pids 11 | *.pid 12 | *.seed 13 | *.pid.lock 14 | 15 | # Directory for instrumented libs generated by jscoverage/JSCover 16 | lib-cov 17 | 18 | # Coverage directory used by tools like istanbul 19 | coverage 20 | 21 | # nyc test coverage 22 | .nyc_output 23 | 24 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 25 | .grunt 26 | 27 | # Bower dependency directory (https://bower.io/) 28 | bower_components 29 | 30 | # node-waf configuration 31 | .lock-wscript 32 | 33 | # Compiled binary addons (https://nodejs.org/api/addons.html) 34 | build/Release 35 | 36 | # Dependency directories 37 | node_modules/ 38 | jspm_packages/ 39 | 40 | # TypeScript v1 declaration files 41 | typings/ 42 | 43 | # Optional npm cache directory 44 | .npm 45 | 46 | # Optional eslint cache 47 | .eslintcache 48 | 49 | # Optional REPL history 50 | .node_repl_history 51 | 52 | # Output of 'npm pack' 53 | *.tgz 54 | 55 | # Yarn Integrity file 56 | .yarn-integrity 57 | 58 | # dotenv environment variables file 59 | .env 60 | 61 | # next.js build output 62 | .next 63 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "trailingComma": "es5" 4 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 David Morrow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-pug-to-html 2 | convert Vue files from pug templates to html 3 | 4 | Will convert `.pug` files and `.vue` files that have a pug template 5 | 6 | ```shell 7 | npm i -g vue-pug-to-html 8 | cd { your directory of files to convert } 9 | pugToHtml 10 | ``` 11 | 12 | Thats it, converts your pug template to html. 13 | -------------------------------------------------------------------------------- /bin/engines/pug.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const pug = require("pug"); 4 | const fs = require("fs"); 5 | 6 | module.exports = function(filePath) { 7 | const contents = fs.readFileSync(filePath, "utf-8"); 8 | let html = ""; 9 | 10 | return { 11 | name: "pug", 12 | 13 | convertTemplate() { 14 | console.log(filePath, contents); 15 | html = pug.render(contents, { pretty: true }); 16 | return html; 17 | }, 18 | 19 | saveToFile() { 20 | fs.writeFileSync(filePath.replace(".pug", ".html"), html); 21 | }, 22 | }; 23 | }; 24 | -------------------------------------------------------------------------------- /bin/engines/vue.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const pug = require("pug"); 4 | const fs = require("fs"); 5 | 6 | module.exports = function(filePath) { 7 | const contents = fs.readFileSync(filePath, "utf-8"); 8 | let html = ""; 9 | 10 | function findTemplateRaw() { 11 | return contents.split(`")[0]; 12 | } 13 | 14 | function findTemplate() { 15 | let lines = findTemplateRaw() 16 | .split("\n") 17 | .filter(row => row !== ""); 18 | 19 | if (lines[0].startsWith(" ")) lines = lines.map(line => line.replace(" ", "")); 20 | return lines.join("\n"); 21 | } 22 | 23 | return { 24 | name: "vue", 25 | 26 | hasVueTemplate() { 27 | return contents.includes(`