Door Gaya Kessler / @GayaNinja
Senior Lead Front End Web Developer Manager Ninja Software Engineer Recruiter Specialist
bij Radish Concepts
Site: http://gaya.ninja
Blog: http://www.gayadesign.com
Twitter: @GayaNinja
(die Gaya Kessler heten)
Frontenden voor WordPress zonder WordPress is mogelijk.
WordPress forceert PHP in de workflow
Want klagen kan iedereen.
<?php
$thumb_id = get_post_thumbnail_id($post->ID);
$url = wp_get_attachment_url($thumb_id);
?>
<img src="<?php echo $url; ?>"
alt="Thumbnail for <?php echo $post->post_title; ?>" />
<img src="{{ post.thumbnail.src }}" alt="Thumbnail for Timber" />
//get base information
var base = require("./data/timber.json");
//read files in ./views/
var files = fs.readdirSync("./views");
files.forEach(function handleFile (file) {
//doStuff( base );
});
var template = Twig.twig({
path: "./views/" + file,
async: false
});
var data = base;
//check if *.json exists
var templateData = file.replace(".twig", ".json");
if (fs.existsSync("./data/" + templateData)) {
//add the information
_.extend(data, require("./data/" + templateData));
}
fs.writeFile("./dist/" + file.replace(".twig", ".html"),
template.render(data));
var base = require("./data/timber.json");
var files = fs.readdirSync("./views");
files.forEach(function (file) {
var template = Twig.twig({
path: "./views/" + file,
async: false
});
var data = base;
//check if *.json exists
var templateData = file.replace(".twig", ".json");
if (fs.existsSync("./data/" + templateData)) {
//add the information
_.extend(data, require("./data/" + templateData));
}
fs.writeFile("./dist/" + file.replace(".twig", ".html"),
template.render(data));
});