Comments (9)
Okay, I apologize. I just noticed in the docs that I needed to use each _collection do |item|
if I want to use each_with_index. I tried each_with_index earlier, and got an error in Ruby. I just tried this format right now, and I am getting that same error. The error is: NoMethodError: undefined method
<<' for nil:NilClass`
Updated code to use proper method:
<div class="panel-group" id="post-panels">
{{ each page._posts do |post| }}
<div class="panel panel-default">
<div class="panel-heading clearfix">
<div class="pull-left">
<a class="panel-title" data-toggle="collapse" data-parent="#post-panels" href="#{{ index }}">{{ post._title }}</a>
</div>
<div class="pull-right">
dfadf
</div>
</div>
<div id="{{ index }}" class="panel-collapse collapse">
<div class="panel-body">
Anim pariatur cliche...
</div>
</div>
</div>
{{ end }}
</div>
Even this simple bit of code gives the error:
<div class="panel-group" id="post-panels">
{{ each page._posts do |post| }}
{{ index }}
{{ end }}
</div>
Full stack trace for this error:
NoMethodError: undefined method `<<' for nil:NilClass
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/html_parser/view_handler.rb:28:in `text'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/html_parser/sandlebars_parser.rb:100:in `text'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/html_parser/sandlebars_parser.rb:89:in `block in parse'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/html_parser/sandlebars_parser.rb:51:in `loop'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/html_parser/sandlebars_parser.rb:51:in `parse'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/html_parser/sandlebars_parser.rb:43:in `initialize'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/html_parser/view_parser.rb:17:in `new'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/html_parser/view_parser.rb:17:in `initialize'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/component_templates.rb:41:in `new'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/component_templates.rb:41:in `block in generate_view_code'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/component_templates.rb:36:in `each'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/component_templates.rb:36:in `generate_view_code'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/component_templates.rb:14:in `code'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/rack/component_code.rb:20:in `block in code'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/rack/component_code.rb:19:in `each'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/rack/component_code.rb:19:in `code'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/component_handler.rb:23:in `compile_for_component'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server/component_handler.rb:17:in `call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/urlmap.rb:65:in `block in call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `each'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/showexceptions.rb:24:in `call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/commonlogger.rb:33:in `call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/etag.rb:23:in `call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in `call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/volt-0.8.18/lib/volt/server.rb:42:in `call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/thin-1.6.3/lib/thin/connection.rb:86:in `block in pre_process'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/thin-1.6.3/lib/thin/connection.rb:84:in `catch'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/thin-1.6.3/lib/thin/connection.rb:84:in `pre_process'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `call'
/home/kinginky/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `block in spawn_threadpool'
127.0.0.1 - - [01/Nov/2014 22:42:36] "GET /components/main.js HTTP/1.1" 500 107245 0.3977
from volt.
ok, so there's two things going on here.
-
I haven't implemented
{{ something.each_with_index do |val, idx| }}
yet. Currently it does provide "index" as a method you can call inside of an .each binding to get the current index (without using .each_with_index) -
This is kind of a binding bug. Basically at the moment you can't assign id's with bindings in them. I'll fix this. It should work in any other attribute.
from volt.
@ryanstout thanks for the quick reply. I've been poring over the code since I posted this trying to get an idea for what all is going on there.
Do you want to point me in the right direction as to how to enable this for id attributes and let me take a stab at it so you can keep your focus on other things? Is this a big and heavy change, or something like a quick regex change, or what?
If you can help get me in the right direction and a basic idea of what I need to do to accomplish this, I have a couple hours to spare right now and would love to contribute.
Thanks again.
from volt.
@Inkybro Unfortunately it's a pretty big change in the depths of the renderer. It's on my todo list. In the mean time, you can probably accomplish the same thing without using indexed id's. Using reactive bindings can take a little while to change how you build stuff to let the bindings do the work. What are you trying to build here? Maybe I can put a simple example together. (Obviously having bindings in id's will be important for somethings, but I was thinking in the mean time....)
from volt.
@ryanstout I understand that. I am actually just using bootstrap 3 here. I just want to use Bootstrap's collapse on panels to show/hide the panel content for each "post" (see: http://getbootstrap.com/javascript/#collapse). I use Bootstrap and JS only when I need to (although I am doing this pet project to get a better feel for JS and what may be "the next thing" -- Volt looks awesome and has a lot of potential), so I know my way around all that to a certain extent, but my expertise lies in Ruby/backend. As a result, I'm at a bit of a loss as to how to get this working.
Again, I am aware and understand that Volt is just getting going, so it may just not be doable for now. In any case, if you can point me in the right direction with this, that'd be greatly appreciated.
from volt.
Yea, it doesn't look like bootstrap's version would work out of the gate. Let me make a demo on my end though just using pure volt. (Should take 10 minutes :-)
from volt.
That's what I presumed. I have more questions I'd like to ask, if you have a few minutes. If you're too busy, an example would suffice just fine. If you do have a few minutes, is there any way I can contact you outside of Github (IRC, Skype, AIM), or should I just ask here?
Thanks again Ryan
from volt.
@Inkybro I'm on gitter most of the time if you want to hit me up there: https://gitter.im/voltrb/volt
from volt.
@ryanstout closing the issue for now. Thanks again, you've been great, and I look forward to all that Volt has to offer. Would love to offer something back if the chance presents itself.
from volt.
Related Issues (20)
- Deployment with docker impossible, missing node.js HOT 3
- `config.try` doesn't work in the server? HOT 4
- How to use Volt::Boolean? HOT 2
- Following todos tutorial update does not work HOT 4
- DDP HOT 2
- Volt, Crawlers and SEO HOT 1
- Disable persistence layer (volt-mongo) on Volt HOT 2
- Volt Future related questions HOT 1
- Server won't start - broken dependency on listen / rb-inotifier gems HOT 1
- Server process doesn't actually stop
- I18n HOT 1
- Has this project been abandoned? HOT 18
- Volt Status HOT 1
- docs at voltframework.com/docs are only visible through a workaround
- Fork Volt HOT 6
- This project is dead? HOT 2
- Is this project definitely dead? HOT 1
- Reborn Volt
- "Connection lost..." smoth offline data and resync
- Link to Opal needs to be switched from .org to .com
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from volt.