Skip to content

Instantly share code, notes, and snippets.

@MattCheely
MattCheely / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@MattCheely
MattCheely / datePicker.html
Created July 31, 2012 21:15
Template inheritance for form handling
<div id="{{$fieldId}}{{/fieldId}}" class="{{#required}}required{{/required}} lulu-datepicker field {{$fieldClass}}{{/fieldClass}}">
<label for="{{$id}}{{/id}}">
{{$label}}{{/label}}
</label>
<input type="text" id="{{$id}}{{/id}}" name="{{name}}" value="{{$value}}{{value}}{{/value}}" disabled />
<a href="#">
<img src="{{application.shared.imgRoot}}/cal01.png" alt="{{$clickText}}{{#i18n}}global.datepicker.clickToSelect{{/i18n}}{{/clickText}}" />
</a>
<div class="description">{{dateFormat}}</div>
<ul class="errors">
@MattCheely
MattCheely / portal:about-me:html
Created July 31, 2012 21:07
Page layout templates using mustache inheritance.
{{! this is a specific (dummy) page with a menu in the 'portal' application}}
{{< portal/prototypes/menuPage.html}}
{{$pageId}}aboutMe{{/pageId}}
{{$pageTitle}}
{{#i18n}}aboutMe.title{{/i18n}}
{{/pageTitle}}
{{$pageContent}}
{{#i18n}}aboutMe.title{{/i18n}}
{{/pageContent}}
@Test
public void testSurprisingBehavior() throws Exception {
final class Book {
public String title;
public Book(String title) {
this.title = title;
}
}
@MattCheely
MattCheely / HoganIssue.js
Created May 28, 2012 20:42
Bad lambda handling with inheritance example
var prototype = Hogan.compile('<div class="content-one">{{$content1}}{{/content1}}</div>\n<div class="content-two">{{$content2}}{{/content2}}</div>');
var sub = Hogan.compile('{{< prototype}}{{$content1}}{{#i18n}}content{{/i18n}}{{/content1}}{{/ prototype}}');
function translateLambda() {
return function(message) {
console.log(message); //logs '}{{/con'
return 'translated ' + message;
}
}
var rendered = sub.render({i18n: translateLambda}, {prototype: prototype});
@MattCheely
MattCheely / inheritance-test.html
Created March 31, 2012 03:00
Hogan.js inheritance failure case
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="hogan-TEST.js"></script>
<script id="parent" type="template/mustache">
This is a parent template.<br/>
{{$content}}Child content goes here{{/content}}<br/>
Ending the parent template.<br/>
</script>
@MattCheely
MattCheely / inputField.html
Created March 24, 2012 00:43
Sample Templates
<div class="field {{classFromName}} {{#required}}required{{/required}}">
<label for="{{id}}">
{{label}}
{{#required}}
<span class="required">{{#i18n}}input.required{{/i18n}}</span>
{{/required}}
</label>
<input type="text" name="{{name}}" value="{{value}}" id="{{id}}"/>
{{#errors}}
<div class="error">{{message}}</div>