David Trasbo wrote:

> ==========
> def dropify(content)
>   s = StringScanner.new(content)
>   output = ""
>   previous_end = 0
>   while s.scan_until(/\{/)
>     output << content[previous_end, s.pointer - previous_end - 1]
>     partial =  s.scan(/\w+/)
>     s.skip /\s+/
>     arguments = {}
>     while argument = s.scan(/\w+:\w+/)
>       name, value = argument.split(/:/)
>       arguments[name.to_sym] = value
>       s.skip /\s+/
>     end
>     s.skip_until /\}/
>     previous_end = s.pointer
>     output << render(:partial => "drops/#{partial}", :locals => 
> arguments)
>   end
>   output << content[s.pointer, content.length - s.pointer]
> end
> ==========

Okay, I actually have a concern about this method. Right now it only 
accepts this kind of syntax:

{test foo:foo_bar}

Since spaces are not covered by \w+ this is not accepted:

{test foo:foo bar}

So I tried changing \w+ to .+ but of course that is never going to work. 
E.g. if I try to pass multiple arguments to the partial like this:

{test foo:foo bar bar:bar foo}

then only one argument will only be passed (foo) and it will have this 
value: "foo bar bar" because the .+ includes that.

But what about putting quotation marks around it?

".+"

Still the same problem. Now foo will just have this value: "“foo bar” 
bar". So, here is my question: How can I make this method accept 
multiple arguments without being limited to that the values have to 
match "\w+"?

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to