Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/nesting/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
'presets' : ['es2015', 'react']
}
10 changes: 10 additions & 0 deletions examples/nesting/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script src="./bundle.js"></script>
</body>
</html>
33 changes: 33 additions & 0 deletions examples/nesting/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/** @jsx h */
import './index.html';
import {h, Cream, create, inject, _container } from '../../../';
import Store from './store';
import Record from './record';

var c =create({
element : document.body,
elementId : 'application',
elementClass : 'cake-application'
})
.route('/', 'records.index')

Cream.extend({
_namespace: 'records.index',

render: function() {
return (
<div>
<h2>List of Records</h2>
{Store.store.map(function(r, i) {
return (
<Record title={i + '. ' + r.title}>
<em>{r.content}</em>
</Record>
);
})
}
</div>
);
}
});

13 changes: 13 additions & 0 deletions examples/nesting/app/record.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @jsx h */
import {h, Cream} from '../../../';

export default Cream.extend({
render: function() {
return (
<div>
<h3>{this.props.title}</h3>
<div>{this.props.children}</div>
</div>
);
}
});
13 changes: 13 additions & 0 deletions examples/nesting/app/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {Cream} from '../../../';

export default Cream.extend({
byId: function(id) {
return this.store[id];
},

store: [
{ title: 'First record', content: 'First record content' },
{ title: 'Second record', content: 'Second record content' },
{ title: 'Third record', content: 'Third record content' }
]
});
13 changes: 13 additions & 0 deletions examples/nesting/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "example",
"author": "Svetlana Linuxenko <linuxenko@yahoo.com> (http://www.linuxenko.pro)",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.18.2",
"babel-loader": "^6.2.8",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"file-loader": "^0.9.0",
"webpack": "^1.13.3"
}
}
49 changes: 49 additions & 0 deletions examples/nesting/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* global __dirname */

var path = require('path');

var webpack = require('webpack');
var dir_js = path.resolve(__dirname, 'app');
var dir_build = path.resolve(__dirname, 'build');

module.exports = {
entry: {
app : path.resolve(dir_js, 'index.js')
},
devtool: 'source-map',
output: {
path: dir_build,
filename: 'bundle.js'
},
resolveLoader: {
fallback: [path.join(__dirname, 'node_modules')]
},
resolve: {
modulesDirectories: ['node_modules', '../../../', dir_js],
fallback: [path.join(__dirname, 'node_modules')]
},
devServer: {
contentBase: dir_build,
},
module: {
loaders: [
{
loader: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/,
presets : ['es2015', 'react']
},
{
test : /\.html$/,
loader : 'file?name=[name].html'
}
]
},
plugins: [
new webpack.NoErrorsPlugin()

],
stats: {
colors: true
}
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cakejs2",
"version": "0.0.19",
"version": "0.1.0",
"description": "Lightweight front-end framework with only best parts and features of most awesome frameworks.",
"main": "index.js",
"files": [
Expand All @@ -12,7 +12,7 @@
"LICENSE"
],
"dependencies": {
"basic-virtual-dom": "^0.2.6"
"basic-virtual-dom": "^0.3.1"
},
"devDependencies": {
"browserify": "^13.1.1",
Expand Down
17 changes: 17 additions & 0 deletions tests/cream.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var expect = require('chai').expect;
var Bakery = require('../');
var Cream = Bakery.Cream;
var h = require('../').h;

describe('Cream for the cake', function() {
afterEach(function() {
Expand Down Expand Up @@ -362,4 +363,20 @@ describe('Cream for the cake', function() {
expect(b.text).to.be.a('function');
expect(b.get('text')).to.be.equal('123');
});

it('should handle nested creams', function() {
var Nested = Cream.extend({
render: function() {
return h('div', null, this.props.name);
}
});

var Wrapper = Cream.extend({
render: function() {
return h(Nested, {name: 'prop-from-root'});
}
});

expect(Wrapper.render().children[0].children).to.be.equal('prop-from-root');
});
});