Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Add Documentation on mustache Lambdas #4

maxstudener opened this Issue · 7 comments

2 participants

@maxstudener shows how in javascript you can you return a function but how does rails call it.

For example im using faye to broadcast a private message, i want javascript to run a function called check_acces and i want rails to run a function called check_acces when the page is reloaded


You can use or lambda.



   a = {
      url: product_url(product),
      title: product.title,
      price: number_to_currency(product.price),
      description: product.description,
      test_info: { 2 + 2 }
   <%= render "products/product", mustache: a %>

what im trying to is something like this

can_edit: {user == current_user}

that works for a render, but not when i publish the result to subscribers, id need javascript end to execute the proc too

var a = {
  title: "title",
  can_edit: function(){
    // do something

The same for js - use js function.


i see my issue i was trying to make my a ={} return a function that render and a call via ajax json request could both use but that doesn't actually make sense i just need to recode the proc in both the ruby and javascript, this was uber helpful


Perfect. So Can I close issue?


yup although it would be nice to see it in the readme but this issue is closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.