Call a function inside an underscore template using backbone

前端 未结 3 1882
长情又很酷
长情又很酷 2021-01-11 10:11

Just a thing I try to do that would really simplify my life right now.

How can I do that :

This is my view in app file

    window.ArtView = B         


        
3条回答
  •  Happy的楠姐
    2021-01-11 10:27

    this is how I did it , it works fine.

    template: _.template(templateText , {
                imports : {
                    check :function (val){
                        // blah blah
                        }
                    }
                }
            }),
    

    then in your html template

    <%= check('value') %>
    

提交回复
热议问题