├── .gitattributes ├── .npmignore ├── docs ├── Gemfile ├── .gitignore ├── assets │ ├── css │ │ └── style.scss │ ├── fonts │ │ ├── Noto-Sans-700 │ │ │ ├── Noto-Sans-700.eot │ │ │ ├── Noto-Sans-700.ttf │ │ │ ├── Noto-Sans-700.woff │ │ │ ├── Noto-Sans-700.woff2 │ │ │ └── Noto-Sans-700.svg │ │ ├── Noto-Sans-italic │ │ │ ├── Noto-Sans-italic.eot │ │ │ ├── Noto-Sans-italic.ttf │ │ │ ├── Noto-Sans-italic.woff │ │ │ └── Noto-Sans-italic.woff2 │ │ ├── Noto-Sans-regular │ │ │ ├── Noto-Sans-regular.eot │ │ │ ├── Noto-Sans-regular.ttf │ │ │ ├── Noto-Sans-regular.woff │ │ │ └── Noto-Sans-regular.woff2 │ │ └── Noto-Sans-700italic │ │ │ ├── Noto-Sans-700italic.eot │ │ │ ├── Noto-Sans-700italic.ttf │ │ │ ├── Noto-Sans-700italic.woff │ │ │ └── Noto-Sans-700italic.woff2 │ └── js │ │ └── scale.fix.js ├── thumbnail.png ├── script │ ├── bootstrap │ ├── cibuild │ └── release ├── another-page.md ├── .travis.yml ├── _config.yml ├── jekyll-theme-minimal.gemspec ├── CONTRIBUTING.md ├── _sass │ ├── fonts.scss │ ├── rouge-github.scss │ └── jekyll-theme-minimal.scss ├── _layouts │ └── default.html ├── CODE_OF_CONDUCT.md ├── index.md ├── README.md └── LICENSE ├── spec ├── support │ └── jasmine.json ├── windowMock.js ├── documentMock.js ├── scriptSpec.js ├── templateSpec.js ├── cssSpec.js └── pluginSpec.js ├── .eslintignore ├── .gitignore ├── examples ├── build.js ├── js_in_different_file.vue ├── js_in_different_file.js ├── index.html ├── component.html ├── using_alias.vue ├── app.js ├── component.vue ├── cordova │ ├── config.xml │ └── res │ │ └── README.md ├── demo │ ├── component.vue │ ├── component.html │ ├── async.vue │ ├── app.js │ ├── home.vue │ ├── inner_template.vue │ └── index.html ├── package.json ├── Gruntfile.js └── require-vuejs.js ├── src ├── require-vuejs.js ├── vue.js ├── template_parser.js ├── template_preprocessor.js ├── css_parser.js ├── plugin.js └── style_import.js ├── .codeclimate.yml ├── .travis.yml ├── bower.json ├── CONTRIBUTING.md ├── .eslintrc.js ├── LICENSE ├── package.json ├── CODE_OF_CONDUCT.md ├── dist ├── require-vuejs.min.js └── require-vuejs.js ├── Gruntfile.js └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | docs/ 2 | examples/ 3 | -------------------------------------------------------------------------------- /docs/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | .sass-cache 3 | Gemfile.lock 4 | *.gem 5 | -------------------------------------------------------------------------------- /docs/assets/css/style.scss: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | @import "jekyll-theme-minimal"; 5 | -------------------------------------------------------------------------------- /spec/support/jasmine.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec_dir": "spec", 3 | "random": true 4 | } 5 | -------------------------------------------------------------------------------- /docs/thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/thumbnail.png -------------------------------------------------------------------------------- /docs/script/bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | gem install bundler 6 | bundle install 7 | -------------------------------------------------------------------------------- /docs/script/cibuild: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | bundle exec jekyll build 6 | gem build jekyll-theme-minimal.gemspec 7 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | dist/* 3 | examples/require-vuejs.js 4 | examples/node_modules/* 5 | examples/dist/* 6 | coverage/* 7 | -------------------------------------------------------------------------------- /docs/another-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | --- 4 | 5 | ## Welcome to another page 6 | 7 | _yay_ 8 | 9 | [back](./) 10 | -------------------------------------------------------------------------------- /docs/.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | cache: bundler 3 | sudo: false 4 | rvm: 2.2 5 | 6 | install: script/bootstrap 7 | script: script/cibuild 8 | -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-700/Noto-Sans-700.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-700/Noto-Sans-700.eot -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-700/Noto-Sans-700.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-700/Noto-Sans-700.ttf -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-700/Noto-Sans-700.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-700/Noto-Sans-700.woff -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-700/Noto-Sans-700.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-700/Noto-Sans-700.woff2 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .grunt/ 3 | _SpecRunner.html 4 | examples/dist/ 5 | *~ 6 | coverage 7 | *.swp 8 | *.log 9 | examples/main-built.js 10 | .idea 11 | -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.eot -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.ttf -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.woff -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.woff2 -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.eot -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.ttf -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.woff -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.woff2 -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.eot -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.ttf -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff -------------------------------------------------------------------------------- /docs/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgardleal/require-vuejs/HEAD/docs/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff2 -------------------------------------------------------------------------------- /examples/build.js: -------------------------------------------------------------------------------- 1 | ({ 2 | baseUrl: ".", 3 | paths: { 4 | "Vue": "https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.1/vue", 5 | "vue": "require-vuejs" 6 | }, 7 | name: "app", 8 | out: "main-built.js" 9 | }) 10 | -------------------------------------------------------------------------------- /examples/js_in_different_file.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/require-vuejs.js: -------------------------------------------------------------------------------- 1 | /* jshint ignore:start */ 2 | if (typeof define !== "function") { 3 | var define = require("amdefine")(module); 4 | } 5 | /* jshint ignore:end */ 6 | 7 | define("require_vuejs", ["plugin"], function(plugin){ 8 | return plugin; 9 | }); 10 | /*vim: set ts=4 ex=4 tabshift=4 expandtab :*/ 11 | -------------------------------------------------------------------------------- /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | engines: 2 | eslint: 3 | enabled: true 4 | duplication: 5 | enabled: true 6 | config: 7 | languages: 8 | - javascript 9 | 10 | exclude_paths: 11 | - "node_modules/*" 12 | - "dist/*" 13 | - "examples/require-vuejs.js" 14 | - "examples/node_modules/*" 15 | - "examples/dist/*" 16 | - "coverage/*" 17 | -------------------------------------------------------------------------------- /spec/windowMock.js: -------------------------------------------------------------------------------- 1 | /* 2 | * windowMock.js 3 | * Copyright (C) 2017 4 | * 5 | * Distributed under terms of the MIT license. 6 | */ 7 | define(["../spec/documentMock"], function(document) { 8 | "use strict"; 9 | return { 10 | document: document 11 | }; 12 | }); 13 | /* vim: set tabstop=4 softtabstop=4 shiftwidth=4 expandtab : */ 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6.11.0" 4 | env: 5 | - ENVIRONMENT=prod 6 | 7 | before_install: 8 | - "npm install -g grunt" 9 | - "npm install -g istanbul" 10 | - "npm install -g eslint@4.0.0" 11 | - npm install 12 | script: 13 | - grunt 14 | - npm test 15 | - istanbul cover node_modules/jasmine-node/bin/jasmine-node spec/ 16 | -------------------------------------------------------------------------------- /src/vue.js: -------------------------------------------------------------------------------- 1 | /** 2 | * vue.js 3 | * Copyright (C) 2017 4 | * 5 | * Distributed under terms of the MIT license. 6 | */ 7 | /* jshint ignore:start */ 8 | if (typeof define !== "function") { 9 | var define = require("amdefine")(module); 10 | } 11 | /* jshint ignore:end */ 12 | 13 | define("vue", ["plugin"], function(plugin) { 14 | return plugin; 15 | }); 16 | /* vim: set tabstop=4 softtabstop=4 shiftwidth=4 expandtab : */ 17 | -------------------------------------------------------------------------------- /examples/js_in_different_file.js: -------------------------------------------------------------------------------- 1 | 2 | define([], function() { 3 | return { 4 | data: () => ({ 5 | message: '', 6 | clickcount: 0, 7 | }), 8 | methods: { 9 | inc() { 10 | this.clickcount += 1; 11 | }, 12 | click() { 13 | this.inc(); 14 | this.message = this.clickcount + ' Clicks'; 15 | }, 16 | }, 17 | }; 18 | }); 19 | -------------------------------------------------------------------------------- /examples/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Require Vue 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "require-vuejs", 3 | "description": "A RequireJS plugin to load and parse VueJS components ( .vue )", 4 | "main": "src/require-vuejs.js", 5 | "authors": [ 6 | "Edgard Leal" 7 | ], 8 | "license": "MIT", 9 | "keywords": [ 10 | "javascript", 11 | "vuejs", 12 | "require" 13 | ], 14 | "homepage": "https://github.com/edgardleal/require-vuejs", 15 | "ignore": [ 16 | "**/.*", 17 | "node_modules", 18 | "bower_components", 19 | "test", 20 | "tests" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | title: require-vuejs 2 | description: A plugin to integrate Require.js and Vue.js 3 | show_downloads: true 4 | google_analytics: 5 | theme: 6 | github: 7 | repository_name: require-vuejs 8 | owner_name: edgardleal 9 | build_revision: 1.0.6 10 | repository_url: https://github.com/edgardleal/require-vuejs 11 | owner_url: https://github.com/edgardleal 12 | zip_url: https://github.com/edgardleal/require-vuejs/archive/1.0.6.zip 13 | tar_url: https://github.com/edgardleal/require-vuejs/archive/1.0.6.tar.gz 14 | -------------------------------------------------------------------------------- /examples/component.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 16 | 17 | 23 | /* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab : */ 24 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # Reporting issues 3 | 4 | You can create issues [here](https://github.com/edgardleal/require-vuejs/issues) 5 | 6 | # With documentation 7 | > You can improve README.md file or examples and send me a pullrequest. 8 | 9 | # Coding 10 | > You can fork this project and after make the changes create a pull request. 11 | 12 | Note, there are some rules described in file `.eslintrc.js`: 13 | 14 | - End of file should be CF ( unix ) 15 | - Identation should be with four spaces ( not tabs ) 16 | - Use double quotes, don't single quotes 17 | - Aways use semicolons at the end of lines 18 | 19 | > All these rules are to facilitate the merge process avoiding conflicts. 20 | -------------------------------------------------------------------------------- /examples/using_alias.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 20 | 21 | 28 | /* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab : */ 29 | -------------------------------------------------------------------------------- /docs/jekyll-theme-minimal.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | Gem::Specification.new do |s| 4 | s.name = "jekyll-theme-minimal" 5 | s.version = "0.0.4" 6 | s.license = "CC0-1.0" 7 | s.authors = ["Steve Smith", "GitHub, Inc."] 8 | s.email = ["opensource+jekyll-theme-minimal@github.com"] 9 | s.homepage = "https://github.com/pages-themes/minimal" 10 | s.summary = "Minimal is a Jekyll theme for GitHub Pages" 11 | 12 | s.files = `git ls-files -z`.split("\x0").select do |f| 13 | f.match(%r{^((_includes|_layouts|_sass|assets)/|(LICENSE|README)((\.(txt|md|markdown)|$)))}i) 14 | end 15 | 16 | s.platform = Gem::Platform::RUBY 17 | s.add_runtime_dependency "jekyll", "~> 3.3" 18 | end 19 | -------------------------------------------------------------------------------- /examples/app.js: -------------------------------------------------------------------------------- 1 | /* global requirejs, require */ 2 | /** 3 | * app.js 4 | * 5 | * Distributed under terms of the MIT license. 6 | */ 7 | 8 | requirejs.config({ 9 | waitSeconds: 1, 10 | paths: { 11 | "Vue": "https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue", 12 | "vue": ["require-vuejs", "https://rawgit.com/edgardleal/require-vuejs/master/dist/require-vuejs"], 13 | "alias": "using_alias" 14 | }, 15 | shim: { 16 | "Vue": {"exports": "Vue"} 17 | } 18 | }); 19 | 20 | require([ 21 | "Vue", 22 | "vue!js_in_different_file", 23 | "vue!component", 24 | "vue!component.html", 25 | "vue!using_alias", 26 | ], function(Vue, comp){ 27 | 28 | window.Vue = Vue; 29 | Vue.component('count-click', comp); 30 | new Vue({ 31 | el: "#app" 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "browser": true, 4 | "node": true 5 | }, 6 | "plugins": [ 7 | "vue" 8 | ], 9 | "globals": { 10 | "require": true, 11 | "requirejs": true, 12 | "define": true, 13 | "template": true, 14 | }, 15 | "extends": [ 16 | "eslint:recommended", 17 | ], 18 | "globals": { 19 | "require": true, 20 | "define": true 21 | }, 22 | "rules": { 23 | "indent": [ 24 | "error", 25 | 4 26 | ], 27 | "linebreak-style": [ 28 | "error", 29 | "unix" 30 | ], 31 | "quotes": [ 32 | "error", 33 | "double" 34 | ], 35 | "semi": [ 36 | "error", 37 | "always" 38 | ] 39 | } 40 | }; 41 | -------------------------------------------------------------------------------- /examples/component.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 23 | 24 | 39 | /* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab : */ 40 | -------------------------------------------------------------------------------- /docs/script/release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Tag and push a release. 3 | 4 | set -e 5 | 6 | # Make sure we're in the project root. 7 | 8 | cd $(dirname "$0")/.. 9 | 10 | # Make sure the darn thing works 11 | 12 | bundle update 13 | 14 | # Build a new gem archive. 15 | 16 | rm -rf jekyll-theme-minimal-*.gem 17 | gem build -q jekyll-theme-minimal.gemspec 18 | 19 | # Make sure we're on the master branch. 20 | 21 | (git branch | grep -q 'master') || { 22 | echo "Only release from the master branch." 23 | exit 1 24 | } 25 | 26 | # Figure out what version we're releasing. 27 | 28 | tag=v`ls jekyll-theme-minimal-*.gem | sed 's/^jekyll-theme-minimal-\(.*\)\.gem$/\1/'` 29 | 30 | # Make sure we haven't released this version before. 31 | 32 | git fetch -t origin 33 | 34 | (git tag -l | grep -q "$tag") && { 35 | echo "Whoops, there's already a '${tag}' tag." 36 | exit 1 37 | } 38 | 39 | # Tag it and bag it. 40 | 41 | gem push jekyll-theme-minimal-*.gem && git tag "$tag" && 42 | git push origin master && git push origin "$tag" 43 | -------------------------------------------------------------------------------- /docs/assets/js/scale.fix.js: -------------------------------------------------------------------------------- 1 | (function(document) { 2 | var metas = document.getElementsByTagName('meta'), 3 | changeViewportContent = function(content) { 4 | for (var i = 0; i < metas.length; i++) { 5 | if (metas[i].name == "viewport") { 6 | metas[i].content = content; 7 | } 8 | } 9 | }, 10 | initialize = function() { 11 | changeViewportContent("width=device-width, minimum-scale=1.0, maximum-scale=1.0"); 12 | }, 13 | gestureStart = function() { 14 | changeViewportContent("width=device-width, minimum-scale=0.25, maximum-scale=1.6"); 15 | }, 16 | gestureEnd = function() { 17 | initialize(); 18 | }; 19 | 20 | 21 | if (navigator.userAgent.match(/iPhone/i)) { 22 | initialize(); 23 | 24 | document.addEventListener("touchstart", gestureStart, false); 25 | document.addEventListener("touchend", gestureEnd, false); 26 | } 27 | })(document); 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Edgard Rosberg Duarte Leal 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 | -------------------------------------------------------------------------------- /examples/cordova/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | RequireVuejsExample 4 | 5 | A sample Apache Cordova application that responds to the deviceready event. 6 | 7 | 8 | Apache Cordova Team 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/demo/component.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 40 | -------------------------------------------------------------------------------- /examples/demo/component.html: -------------------------------------------------------------------------------- 1 | 29 | 30 | 42 | -------------------------------------------------------------------------------- /examples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "require-vuejs-example-1", 3 | "version": "1.0.3", 4 | "description": "A RequireJS plugin to load and parse VueJS components ( .vue ) ", 5 | "main": "app.js", 6 | "directories": {}, 7 | "scripts": { 8 | "start": "node node_modules/http-server/bin/http-server ./" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/edgardleal/require-vuejs.git" 13 | }, 14 | "keywords": [ 15 | "javascript", 16 | "vuejs", 17 | "require" 18 | ], 19 | "author": "Edgard Leal", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/edgardleal/require-vuejs/issues" 23 | }, 24 | "homepage": "https://github.com/edgardleal/require-vuejs#readme", 25 | "dependencies": { 26 | "http-server": "^0.10.0", 27 | "require-vuejs": "^1.0.9", 28 | "requirejs": "^2.3.3", 29 | "vue": "^2.3.4", 30 | "vue-router": "^2.7.0" 31 | }, 32 | "devDependencies": { 33 | "grunt": "^1.0.1", 34 | "grunt-cli": "^1.2.0", 35 | "grunt-contrib-jasmine": "^1.1.0", 36 | "grunt-contrib-jshint": "^1.1.0", 37 | "grunt-contrib-requirejs": "^1.0.0", 38 | "grunt-contrib-uglify": "^2.2.0", 39 | "grunt-jsmeter": "^0.3.1", 40 | "jasmine-node": "^1.14.5", 41 | "simplehttpserver": "0.0.6" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/demo/async.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 46 | -------------------------------------------------------------------------------- /examples/cordova/res/README.md: -------------------------------------------------------------------------------- 1 | 21 | 22 | Note that these image resources are not copied into a project when a project 23 | is created with the CLI. Although there are default image resources in a 24 | newly-created project, those come from the platform-specific project template, 25 | which can generally be found in the platform's `template` directory. Until 26 | icon and splashscreen support is added to the CLI, these image resources 27 | aren't used directly. 28 | 29 | See https://issues.apache.org/jira/browse/CB-5145 30 | -------------------------------------------------------------------------------- /examples/demo/app.js: -------------------------------------------------------------------------------- 1 | /* global requirejs, require */ 2 | /** 3 | * app.js 4 | * 5 | * Distributed under terms of the MIT license. 6 | */ 7 | 8 | requirejs.config({ 9 | paths: { 10 | "Vue": "https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.min", 11 | "vue": "https://rawgit.com/edgardleal/require-vue/master/dist/require-vuejs", 12 | "vue-router": "https://cdnjs.cloudflare.com/ajax/libs/vue-router/2.7.0/vue-router.min" 13 | }, 14 | shim: { 15 | "Vue": {"exports": "Vue"} 16 | } 17 | }); 18 | 19 | require(["Vue", "vue-router"], function(Vue, VueRouter){ 20 | Vue.use(VueRouter); 21 | var asyncComp = function(componentName) { 22 | return function(resolve) { 23 | require([componentName], resolve); 24 | }; 25 | }; 26 | 27 | var router = new VueRouter({routes: [ 28 | { path: "/home" , component: asyncComp("vue!/demo/home")}, 29 | { path: "/inner", component: asyncComp("vue!/demo/inner_template")}, 30 | { path: "/html" , component: asyncComp("vue!/demo/component.html")}, 31 | { path: "/vue" , component: asyncComp("vue!/demo/component")}, 32 | { path: "/async", component: asyncComp("vue!/demo/async")}, 33 | ]}); 34 | 35 | new Vue({ 36 | data: { 37 | started: new Date() 38 | }, 39 | router: router, 40 | el: "#app" 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /spec/documentMock.js: -------------------------------------------------------------------------------- 1 | /* 2 | * documentMock.js 3 | * Copyright (C) 2017 4 | * 5 | * Distributed under terms of the MIT license. 6 | */ 7 | define([], function() { 8 | "use strict"; 9 | var BaseNode = function(tagName) { 10 | this.tagName = tagName; 11 | this.childs = []; 12 | this.appendChild = function(node) { 13 | this[node.tagName] = node; 14 | this.childs.push(node); 15 | }; 16 | this.createElement = function(tag) { 17 | return new BaseNode(tag); 18 | }; 19 | this.createTextNode = function(text) { 20 | var result = new BaseNode("div"); 21 | result.innerText = text; 22 | return result; 23 | }; 24 | 25 | this.getElementsByTagName = function(name) { 26 | var result = []; 27 | for(var i in this.childs) { 28 | if ( this.childs[i].tagName === name ) { 29 | result.push(this.childs[i]); 30 | } 31 | } 32 | 33 | return result; 34 | }; 35 | 36 | this.querySelector = function(query) { 37 | return this.getElementsByTagName(query); 38 | }; 39 | }; 40 | 41 | var result = new BaseNode(); 42 | result.appendChild(new BaseNode("head")); 43 | result.appendChild(new BaseNode("body")); 44 | 45 | return result; 46 | }); 47 | /* vim: set tabstop=4 softtabstop=4 shiftwidth=4 expandtab : */ 48 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "require-vuejs", 3 | "version": "1.1.3", 4 | "description": "A RequireJS plugin to load and parse VueJS components ( .vue ) ", 5 | "main": "dist/require-vuejs.js", 6 | "author": "Edgard Leal", 7 | "license": "MIT", 8 | "bugs": { 9 | "url": "https://github.com/edgardleal/require-vuejs/issues" 10 | }, 11 | "homepage": "https://edgardleal.github.io/require-vuejs/", 12 | "directories": { 13 | "doc": "docs", 14 | "test": "spec" 15 | }, 16 | "scripts": { 17 | "test": "node node_modules/jasmine-node/bin/jasmine-node ./spec", 18 | "build": "node node_modules/grunt/bin/grunt" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/edgardleal/require-vuejs.git" 23 | }, 24 | "keywords": [ 25 | "javascript", 26 | "vuejs", 27 | "requirejs" 28 | ], 29 | "dependencies": { 30 | "requirejs": "^2.3.3", 31 | "vue": "^2.3.4", 32 | "vue-template-compiler": "^2.3.4" 33 | }, 34 | "devDependencies": { 35 | "eslint": "^3.19.0", 36 | "eslint-config-vue": "^2.0.2", 37 | "eslint-plugin-vue": "^2.1.0", 38 | "grunt": "^1.0.1", 39 | "grunt-cli": "^1.2.0", 40 | "grunt-contrib-copy": "^1.0.0", 41 | "grunt-contrib-jasmine": "^1.1.0", 42 | "grunt-contrib-jshint": "^1.1.0", 43 | "grunt-contrib-requirejs": "^1.0.0", 44 | "grunt-contrib-uglify": "^2.2.0", 45 | "grunt-eslint": "^20.0.0", 46 | "grunt-jscpd": "0.0.12", 47 | "grunt-jsmeter": "^0.3.1", 48 | "jasmine-node": "^1.14.5" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/demo/home.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 53 | -------------------------------------------------------------------------------- /examples/demo/inner_template.vue: -------------------------------------------------------------------------------- 1 | 37 | 38 | 53 | -------------------------------------------------------------------------------- /spec/scriptSpec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * scriptSpec.js 3 | * Copyright (C) 2017 Edgard Leal 4 | * 5 | * Distributed under terms of the MIT license. 6 | */ 7 | /* global describe, it, expect */ 8 | var requirejs = require("requirejs"); 9 | 10 | requirejs.config({ 11 | baseUrl: __dirname + "/../src/", 12 | nodeRequire: require 13 | }); 14 | 15 | var parser = requirejs("script_parser"); 16 | 17 | describe("Script parser", function() { 18 | "use strict"; 19 | it("Extract simple", function() { 20 | var template = ""; 21 | var result = parser.extractScript(template); 22 | 23 | expect(result).toEqual("alert('ok')"); 24 | }); 25 | }); 26 | 27 | describe("Script with attributes", function() { 28 | 29 | it(""; 39 | var result = parser.extractScript(template); 40 | 41 | expect(result).not.toBe(null); 42 | expect(result).toEqual("alert('ok')"); 43 | }); 44 | 45 | it(""; 47 | var result = parser.extractScript(template); 48 | 49 | expect(result).not.toBe(null); 50 | expect(result).toEqual("alert('ok')"); 51 | }); 52 | 53 | }); 54 | 55 | /* vim: set tabstop=4 softtabstop=4 shiftwidth=4 expandtab : */ 56 | -------------------------------------------------------------------------------- /docs/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great. 4 | 5 | Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms. 6 | 7 | ## Submitting a pull request 8 | 9 | 0. [Fork][fork] and clone the repository 10 | 0. Configure and install the dependencies: `script/bootstrap` 11 | 0. Make sure the tests pass on your machine: `script/cibuild` 12 | 0. Create a new branch: `git checkout -b my-branch-name` 13 | 0. Make your change, add tests, and make sure the tests still pass 14 | 0. Push to your fork and [submit a pull request][pr] 15 | 0. Pat your self on the back and wait for your pull request to be reviewed and merged. 16 | 17 | Here are a few things you can do that will increase the likelihood of your pull request being accepted: 18 | 19 | - Follow the [style guide][style]. 20 | - Write tests. 21 | - Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests. 22 | - Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). 23 | 24 | ## Resources 25 | 26 | - [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/) 27 | - [Using Pull Requests](https://help.github.com/articles/using-pull-requests/) 28 | - [GitHub Help](https://help.github.com) 29 | 30 | [fork]: https://github.com/pages-themes/minimal/fork 31 | [pr]: https://github.com/pages-themes/minimal/compare 32 | [style]: http://ben.balter.com/jekyll-style-guide/ 33 | [code-of-conduct]: CODE_OF_CONDUCT.md 34 | -------------------------------------------------------------------------------- /examples/Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | grunt.initConfig({ 4 | pkg: grunt.file.readJSON("package.json"), 5 | jsmeter: { 6 | all: { 7 | files: { 8 | src: ["app.js"] 9 | }, 10 | options: { 11 | dest: "report/", 12 | } 13 | } 14 | }, 15 | requirejs: { 16 | compile: { 17 | options: { 18 | baseUrl: "./", 19 | logLevel: 0, 20 | findNestedDependencies: true, 21 | "normalizeDirDefines": "skip", 22 | "skipDirOptimize": true, 23 | name: "app", 24 | paths: { 25 | "Vue": "node_modules/vue/dist/vue", 26 | "vue": "node_modules/require-vuejs/dist/require-vuejs" 27 | }, 28 | out: "./dist/<%= pkg.name %>.min.js" 29 | } 30 | }, // compile 31 | dese: { 32 | options: { 33 | baseUrl: "./", 34 | name: "app", 35 | paths: { 36 | "Vue": "node_modules/vue/dist/vue", 37 | "vue": "node_modules/require-vuejs/dist/require-vuejs" 38 | }, 39 | optimize: "none", 40 | out: "./dist/<%= pkg.name %>.js" 41 | } 42 | } // dese 43 | } // requirejs 44 | }); 45 | 46 | grunt.loadNpmTasks("grunt-contrib-requirejs"); 47 | grunt.loadNpmTasks("grunt-jsmeter"); 48 | 49 | grunt.registerTask("default", ["requirejs"]); 50 | }; 51 | -------------------------------------------------------------------------------- /spec/templateSpec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * templateSpec.js 3 | * 4 | * Distributed under terms of the MIT license. 5 | */ 6 | /* global describe, it, expect */ 7 | 8 | 9 | var requirejs = require("requirejs"); 10 | 11 | requirejs.config({ 12 | baseUrl: __dirname + "/../src/", 13 | nodeRequire: require 14 | }); 15 | 16 | describe("Setup", function() { 17 | 18 | it("require", function() { 19 | expect(require).not.toBe(null); 20 | var css = requirejs("css_parser"); 21 | expect(css).not.toBe(null); 22 | expect(requirejs("vue")).not.toBe(null); 23 | }); 24 | 25 | }); 26 | 27 | describe("Parser Templates", function() { 28 | var parser = requirejs("template_parser"); 29 | 30 | 31 | it("Simple br", function() { 32 | var template = "" + 33 | "
"; 34 | 35 | var result = parser.extractTemplate(template); 36 | 37 | expect(result).toMatch("
"); 38 | }); 39 | 40 | it("Multiline", function() { 41 | var template = ""; 44 | var result = parser.extractTemplate(template); 45 | var expected = 46 | "'' + \n" + 47 | "' ' + \n" + 48 | "' ' + ''"; 49 | expect(result.length).toBe(expected.length); 50 | expect(true).toBe(result === expected); 51 | }); 52 | 53 | it("Multi tamplate tags", function () { 54 | var template = "" ; 55 | var result = parser.extractTemplate(template); 56 | var expected = "'' + ''"; 57 | 58 | expect(result).toEqual(expected); 59 | 60 | }); 61 | 62 | }); 63 | /* vim: set tabstop=4 softtabstop=4 shiftwidth=4 expandtab : */ 64 | -------------------------------------------------------------------------------- /spec/cssSpec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * scriptSpec.js 3 | * Copyright (C) 2017 Edgard Leal 4 | * 5 | * Distributed under terms of the MIT license. 6 | */ 7 | /* global describe, it, expect */ 8 | var requirejs = require("requirejs"); 9 | 10 | requirejs.config({ 11 | baseUrl: __dirname + "/../src/", 12 | nodeRequire: require 13 | }); 14 | 15 | var document = requirejs("../spec/documentMock"); 16 | 17 | var parser = requirejs("css_parser"); 18 | 19 | describe("CSS parser", function() { 20 | "use strict"; 21 | 22 | it("Setup", function() { 23 | expect(document).not.toBeNull(); 24 | expect(document.head).not.toBeNull(); 25 | }); 26 | 27 | it("Extract simple", function() { 28 | var expected = "#id { display: none}"; 29 | var template = ""; 30 | var result = parser.functionString(template); 31 | var expectedIndex = result.indexOf(expected); 32 | 33 | expect(expectedIndex).not.toBe(-1); 34 | }); 35 | 36 | it("Without style tag", function() { 37 | var template = "