Skip to content

Add Function Support #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Add Function Support #7

wants to merge 3 commits into from

Conversation

icyflash
Copy link

Sometimes we need format data before render.

We have:

{"CreatedAt": 1346295626942}

We need:

Thu Aug 30 2012 11:00:26 GMT+0800

We can:

var template = new t("<div>{{#CreatedAt|dateFormat}}</div>");
template.register("dateFormat",function(data){return new Date(parseInt(data));});
template.render({"CreatedAt": 1346295626942});

For someone need format data before render.
function description
t.min.js
@jasonmoo
Copy link
Owner

jasonmoo commented Sep 5, 2012

Hey I'm not really feeling the function support. I think the same thing can be accomplished by processing your data before you pass it to the render function, or building markup in a loop with a couple templates.

Also you managed to rewrite all the line endings so I can't tell what changes you've made from the diff.

@jasonmoo jasonmoo closed this Sep 5, 2012
Satyam added a commit to Satyam/t.js that referenced this pull request Oct 17, 2023
Fixes jasonmoo#7
Any value tag can be followed by the name of one or several functions to
process the raw value into a form suitable for display.
Contains source, modified Readme and test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants