Skip to content

Commit

Permalink
add mvl
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed Jul 17, 2018
1 parent 01063d9 commit f1630ec
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
Empty file added packages/moon-mvl/README.md
Empty file.
28 changes: 28 additions & 0 deletions packages/moon-mvl/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const fs = require("fs");
const path = require("path");
const Moon = require("moon");

module.exports = function(file, contents) {
let js = "import Moon from \"moon\";";
let css = "";
let dep;

const view = "function(m,instance,locals){" + Moon.compile(this.contents) + "};";
let data = "{};";

const fileName = path.basename(file).slice(0, -4);
const directoryName = path.dirname(file);
if (fs.existsSync(path.join(directoryName, fileName + ".js"))) {
dep = `.${path.sep}${fileName}.js`;
js += `import data from "${dep}";`;
data = "data;";
}

js += `export default Moon.extend("${path.basename(directoryName)}",function(){var options=${data}options.view=${view}return options;});`;

return {
js: js,
css: css,
dep: dep
};
};
27 changes: 27 additions & 0 deletions packages/moon-mvl/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "moon-mvl",
"version": "1.0.0-beta.1",
"description": "Moon MVL component compiler",
"main": "index.js",
"scripts": {
"build": "",
"test": ""
},
"repository": {
"type": "git",
"url": "git+https://github.com/kbrsh/moon.git"
},
"keywords": [
"moon",
"mvl"
],
"author": "Kabir Shah",
"license": "MIT",
"bugs": {
"url": "https://github.com/kbrsh/moon/issues"
},
"homepage": "https://github.com/kbrsh/moon#readme",
"peerDependencies": {
"moon": "*"
}
}

0 comments on commit f1630ec

Please sign in to comment.