Skip to content

Instantly share code, notes, and snippets.

@barneycarroll
Forked from taosx/mithriljsonextract.js
Last active August 29, 2015 14:21
Show Gist options
  • Save barneycarroll/5238d176a2b862a2c6f0 to your computer and use it in GitHub Desktop.
Save barneycarroll/5238d176a2b862a2c6f0 to your computer and use it in GitHub Desktop.
// MODEL
'use strict';
var m = require('mithril');
module.exports = function get_himage(){
return m.request({
method: 'GET',
url: '/config.json'
})
.then(function (data) {
return data["himage"];
});
// COMPONENT
'use strict';
var m = require('mithril');
var get_himage = require('../models/config');
var Slider = module.exports = {
controller: function () {
this.himage = get_himage()
},
view: function (ctrl) {
return m("img[alt='slider image 1'][src='" + ctrl.himage() + "']")
};
// JSON DATA
[
"{\n\t\"title\": \"Site title name\",\n\t\"description\": \"Site description\",\n\t\"keywords\": \"Site, keywords\",\n\t\"aboutus\": \"Site about us\",\n\t\"contact\": {\n\t\t\"phones\": {\n\t\t\t\"fix1\": \"0210545665\",\n\t\t\t\"fix2\": \"0210545665\",\n\t\t\t\"mobile1\": \"0732577794\",\n\t\t\t\"mobile2\": \"0732577794\",\n\t\t\t\"mobile3\": \"0732577794\",\n\t\t\t\"fax1\": \"0210545665\",\n\t\t\t\"fax2\": \"0210545665\"\n\t\t},\n\t\t\"adresses\": {\n\t\t\t\"adress1\": \"Placeholder, A1\",\n\t\t\t\"adress2\": \"Placeholder, A2\"\n\t\t},\n\t\t\"email\": {\n\t\t\t\"email1\": \"adress@email.com\",\n\t\t\t\"email2\": \"adress@email.com\"\n\t\t}\n\t},\n\t\"himage\": \"style/images/slider/slide1.jpg\"\n}"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment