![](/img/trans.png)
[英]How do I use Tensorflow JS with Minima / other Jekyll Themes?
[英]How do I use JSON from a Jekyll _data directory?
按照哲基爾文檔,你可以訪問YAML,JSON和CSV文件中_data
使用目錄{{ site.data.filename }}
我有一個名為chapters.json
的有效geoJson點函數文件。 我能夠訪問該文件,但是當我在javascript中使用該文件時,我看到了一些奇怪的字符。
chapters.json
摘錄:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"title": "MaptimeBER"
},
"geometry": {
"type": "Point",
"coordinates": [
13.391,
52.521
]
}
},
{...}
]
}
例如,當Jekyll處理以下內容時: var chapters = {{ site.data.chapters }};
輸出Javascript是:
var chapters = {"type"=>"FeatureCollection", "features"=>[{"type"=>"Feature", "properties"=> ...
我的問題是,為什么分隔鍵值對的冒號變為=>
? 它導致我的javascript錯誤輸出。
使用jsonify過濾器,它將Hash或Array轉換為JSON:
var chapters = {{ site.data.chapters | jsonify }};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.