简体   繁体   中英

How to access a data file in a plugin generator?

I'd like to access a data file I have in the _data folder and use this in a plugin generator, but I'm not sure how. I have:

site.data.projects.each do |project|
  ...
end

But when I try to compile it tells me "undefined method 'projects' for Hash(...) NoMethodError. What is the correct syntax?

If you post what your _data file looks like I can give you a better answer, but try:

site.data['projects'].each do |project|
  ...
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM