Skip to content

Instantly share code, notes, and snippets.

@ishiduca
Created September 28, 2014 07:28
Show Gist options
  • Save ishiduca/aba6c2440541c49d3cbe to your computer and use it in GitHub Desktop.
Save ishiduca/aba6c2440541c49d3cbe to your computer and use it in GitHub Desktop.
ractivate で ractive.js を brwoserify に対応させる
<!doctype html>
<head>
<meta charset="utf-8" />
<title>Ractiv.ate</title>
<head>
<body>
<div id="main"></div>
<script src="./bundle.js"></script>
</body>
'use strict'
var Ractive = require('ractive')
var ractive = new Ractive({
el: '#main'
, template: require('./template.html')
, data: {
foo: 'bar'
}
})
{
"version": "0.0.1",
"name": "ractivate-demo",
"dependencies": {
"ractivate": "^0.2.0",
"ractive": "^0.5.8"
},
"scripts": {
"build": "browserify -t ractivate ./main.js > ./bundle.js"
}
}
<div>{{foo}}</div>
@ishiduca
Copy link
Author

npm run build すると bundle.js をビルドする。
(実際は browserify -t ractivate ./main.js > ./build.js してるだけ)

$ tree -F -L 2 . してディレクトリ内を見ると

|-- bundle.js
|-- index.html ... アプリページ本体
|-- main.js
|-- node_modules/
|   |-- ractivate/
|   `-- ractive/
|-- package.json
`-- template.html ... テンプレート

詳しくは https://github.com/jrajav/ractivate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment