jsrender register tags not working

Hi,
I am trying to get registertags working so I can format a number.  I can't register it or use it.  Can someone please look?

here is the error: Uncaught TypeError: Object #<Object> has no method 'registerTags'

Fiddle: http://jsfiddle.net/jmillman/LRD6E/15/


var data = {
    people: [{
        name: 'One',
        shirtColor: 'red',
        price: 1.001
    }, {
        name: 'Two',
        shirtColor: 'blue',
        price: 2.0
    }, {
        name: 'Three',
        shirtColor: 'green',
        price: 3.3333333
    }]
};

$.views.registerTags({
    sample: function (val) {
        return val;
    }
});

$.templates({ tmpl: "#template" });
$("#output").html($.render.tmpl(data));
jackjohnson44Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bruce CadizQuality SpecialistCommented:
change $.views.registerTags to $.views.tags

http://www.jsviews.com/#tags%28%29
0
Bruce CadizQuality SpecialistCommented:
Updated your code to do what you wanted: (I think)
http://jsfiddle.net/c336914/LRD6E/16/

actually had to pass the function through on render data call like so
$("#output").html($.render.tmpl(data, {format:myFormat}));

Open in new window

0
jackjohnson44Author Commented:
Thanks.  I thought you didn't have to pass them in though.  I'd rather just register them then refer to the tag.  Having to pass everything will get messy.
0
Bruce CadizQuality SpecialistCommented:
I think you can register them but as a helper

http://www.jsviews.com/#helpers%28%29
0
Bruce CadizQuality SpecialistCommented:
Here's how you can do it

function myFormat(val) {
    return '$ ' + val.toFixed(2)
}

$.views.helpers({
    format: myFormat
});

$("#output").html($.render.tmpl(data));

Open in new window


Working Example here: http://jsfiddle.net/c336914/LRD6E/21/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.