Last active
March 17, 2018 17:12
-
-
Save ycatch/4e2b6e46b741206ee1e5f7d24a52bee8 to your computer and use it in GitHub Desktop.
This file contains 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
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<title>mustache.js | Usage</title> | |
<!-- 部分テンプレート --> | |
<!-- Try this on your Web Server --> | |
<style> | |
body { | |
padding: 30px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="target">Loading...</div> | |
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.2.0/mustache.min.js"></script> | |
<script> | |
$(function() { | |
var obj = { | |
title: "Template Engine", | |
description: "吾輩は猫である。", | |
date: function() { | |
return new Date(); | |
} | |
}; | |
var partials = { | |
subText1: "名前はまだ無い。", | |
subText2: "どこで生れたかとんと見当がつかぬ。" | |
}; | |
$.get('template3.mst', function(template) { | |
var output = Mustache.render(template, obj, partials); | |
$("#target").html(output); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
This file contains 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
<h1>Hello {{title}}</h1> | |
<div>{{date}}</div> | |
<div>{{description}} {{> subText1}} {{> subText2}}</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment