configuration helper function to include template data from a external json file?

조회수 227회
읽지 않은 첫 메시지로 건너뛰기

Pete Schirmer

읽지 않음,
2012. 11. 7. 오후 4:16:0212. 11. 7.
받는사람 doc...@googlegroups.com
attempting something like this in the docpad.coffee file:

docpadConfig = {
  templateData:{
    getJsonData:(path) -> output = docpad.getFile({relativePath:path})
  }
}

any ideas on how to get that to push the data located in the file into an eco template (referenced somewhat like this:) 

<%= @getJsonData('/json/mode1.json').myValue %>


should it be getDatabase or getCollection or something other than getFile? 

Pete Schirmer

읽지 않음,
2012. 11. 12. 오후 5:35:1012. 11. 12.
받는사람 doc...@googlegroups.com
found one solution, a bit of a hack: 

templateData:{
  getJsonData:(path) ->  output =  JSON.parse ( docpad.database.findOne({id:path}).attributes.source)
}



Pete Schirmer

읽지 않음,
2012. 11. 12. 오후 5:39:5712. 11. 12.
받는사람 doc...@googlegroups.com
* I also added /json/ to the layoutsPaths: in the docpadConfig so it would include them in docpad.database, but not copy them into the output directory 
전체답장
작성자에게 답글
전달
새 메시지 0개