Created
February 27, 2015 05:21
-
-
Save 3rd-Eden/c31ead1c17b8393c2b88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM **/ | |
<div> | |
<FormattedMessage | |
message={getIntlMessage('post.meta')} | |
num={props.post.comments.length} | |
ago={<FormattedRelative value={props.post.date} />} | |
/> | |
<span>{random}</span> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM **/ | |
<PostMeta post={post} {...intlData} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// | |
// Required for old node.js builds and io.js | |
// | |
if (!global.Intl) global.Intl = require('intl'); | |
var path = require('path') | |
, React = require('react') | |
, jsx = require('react-jsx') | |
, ReactIntl = require('react-intl') | |
, read = require('fs').readFileSync | |
, IntlMixin = ReactIntl.IntlMixin; | |
var templates = { | |
component: jsx.server(read(path.join(__dirname, 'component.jsx'), 'utf-8')), | |
postmeta: jsx.server(read(path.join(__dirname, 'postmeta.jsx'), 'utf-8')) | |
}; | |
var Component = React.createClass({ | |
mixins: [ReactIntl.IntlMixin], | |
render: function render() { | |
return templates.component({ | |
FormattedMessage: this.FormattedMessage, | |
props: this.props, | |
getIntlMessage: this.getIntlMessage, | |
FormattedRelative: this.FormattedRelative, | |
random: 'lol cakes' | |
}); | |
} | |
}); | |
console.log(templates.postmeta({ | |
PostMeta: Component, | |
post: { | |
date : 1422046290531, | |
comments: [1] | |
}, | |
intlData:{ | |
locales : ['en-US'], | |
messages: { | |
post: { | |
meta: 'Posted {ago}, {num, plural, one{# comment} other{# comments}}' | |
} | |
} | |
} | |
}, { html: true })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment