Home > Mobile >  syntax Error when calling a function with paramaters in slim template
syntax Error when calling a function with paramaters in slim template

Time:03-03

I have a slim template where I call a function like so:

textarea.form-control value = @function(parameter)

However I get the following error:

syntax error, unexpected '(', expecting ')'

Its strange that it does not like the '(" character because thats how I would imagine we would call functions with arguments from a template.What am I doing wrong and how can I call a function with an argument from a slim template. Apologies if this is a basic question, I am very new to slim and ruby

CodePudding user response:

You don’t need the @:

textarea.form-control value = function(parameter)

As long as function and parameter are defined then this should work.

You may be confusing Ruby attributes (which use @) with functions/methods (which don’t). If you want to pass an attribute as the parameter, then you need the @ in front of its name:

textarea.form-control value = @function(@attribute)
  • Related