Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Created January 11, 2010 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenharman/274415 to your computer and use it in GitHub Desktop.
Save stevenharman/274415 to your computer and use it in GitHub Desktop.
public class MyViewModel
{
// other crap...
public string to_metadata()
{
var jq_meta = new
{
required = IsRequired,
messages = new { required = "gimme one, yo!"}
};
return new JQueryMeta().Serialize(jq_meta);
}
}
<!-- usage: -->
<input type="text" class="<%= model.to_metadata() %>" value="<%= model.value " />
<!-- renders: -->
<input type="text" class="{required:true, messages:{ required:'gimme one, yo!' }}" value="<%= model.value " />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment