문제

So I have a database called development.sqlite3 and it is in the same directory as my config.rb.

When I go into IRB and type in the following:

require 'data_mapper'
DataMapper.setup :default, "sqlite://#{Dir.pwd}/development.sqlite3"

class Post
      include DataMapper::Resource
      property :title,      String
      property :slug_url,   String, :key => true
      property :desc,       String
      property :content,    Text
      property :project,    String
      property :target_url, Text
      property :trackback,  Integer
      property :updated_at, String
      property :created_at, DateTime  # A DateTime, for any date you might like.
end


DataMapper.finalize
DataMapper.auto_upgrade!
posts = Post.all 
puts post.slug_url

And this kicks out all the slug_urls like I would expect. Here is what I have at the beginning of of config.rb file.

require 'data_mapper'
require 'builder'
require 'maruku'

DataMapper.setup :default, "sqlite://#{Dir.pwd}/development.sqlite3"

class Post
  include DataMapper::Resource
  property :title,      String
  property :slug_url,   String, :key => true
  property :desc,       String
  property :content,    Text
  property :project,    String
  property :target_url, Text
  property :trackback,  Integer
  property :updated_at, String
  property :created_at, DateTime  # A DateTime, for any date you might like.
end

DataMapper.finalize
DataMapper.auto_upgrade!

posts = Post.all 

posts.each do |post|
  page "/kw/#{post.slug_url}.haml", :proxy => "/kw/template.haml" do
    @slug_url = post.slug_url
  end
end

and my template.haml just has the following in it: = @slug_url

When I run middleman build I get no errors, and it seems to work fine, but it doesn't create the kw directory or any of the files that it should. Any ideas on what I am doing wrong here?

도움이 되었습니까?

해결책

Firstly, "page" takes output paths, not templates paths in the current version (3.0 beta support both formats).

So you'd want to do something like:

page "/kw/#{post.slug_url}.html", :proxy => "/kw/template.html" do
  @slug_url = post.slug_url
end

Where you have a /source/kw/template.html.haml file for dealing with the data.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top