首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >连接Prismic.io和Meteor

连接Prismic.io和Meteor
EN

Stack Overflow用户
提问于 2014-10-20 00:09:14
回答 1查看 299关注 0票数 0

我想使用 javascript开发工具包将内容导入到流星模板中。

首先,我不确定有什么更好,让我的主要流星模板建立空间条。

{{title}}

或者对Prismic.io使用谓词系统

[:d = namespace.operator(<fragment>, <title>)]

(我知道谓词将以某种方式使用,可能会将它们存储在一个变量中,并以某种方式将其传递给空格。)

除此之外,我甚至连我的Meteor应用程序都无法运行。我有以下html文件

test.html

代码语言:javascript
复制
<head>
  <meta charset="utf-8">
  <title>Prismic.io Javascript kit Test Suite</title>
</head>

<template name="test">
  <div id="qunit"></div>
  <div id="qunit-fixture"></div>
</template>

unit.html

代码语言:javascript
复制
<head>
  <meta charset="utf-8">
  <title>Prismic.io Javascript kit Test Suite</title>
</head>
<template name="quint">
  <div id="qunit"></div>
  <div id="qunit-fixture"></div>
</template>

doc.html

代码语言:javascript
复制
<head>
  <meta charset="utf-8">
  <title>Prismic.io Javascript kit Test Suite</title>
</head>
<template name ="doc">
  <div id="qunit"></div>
  <div id="qunit-fixture"></div>
</template>

fragments.html

代码语言:javascript
复制
<head>
  <meta charset="utf-8">
  <title>Prismic.io Javascript kit Test Suite</title>
</head>
<template name="fragments">
  <div id="qunit"></div>
  <div id="qunit-fixture"></div>
</template>

好吧,这是我的问题开始。我有上面提到的来自Prismic.io developer工具包的所有javascript文件在/src , /dis , /libs的客户端文件夹中。

流星把这个长长的错误抛在下面。错误中的第一个引用是future.js:183 with error ReferenceError: window未定义,我最初的猜测是,这是Meteor没有的npm依赖项。我不确定,如果是的话,我怎样才能让这个开发工具包在Meteor工作。或者我必须用meteor向prisimic.io/api发出http请求。

谢谢!任何先进的帮助。

代码语言:javascript
复制
W20141019-16:24:20.945(-7)? (STDERR) 
W20141019-16:24:20.999(-7)? (STDERR) /Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141019-16:24:20.999(-7)? (STDERR)                        throw(ex);
W20141019-16:24:21.000(-7)? (STDERR)                              ^
W20141019-16:24:21.000(-7)? (STDERR) ReferenceError: window is not defined
W20141019-16:24:21.000(-7)? (STDERR)     at app/js/dist/prismic.io-1.0.10.min.js:2:6569
W20141019-16:24:21.000(-7)? (STDERR)     at app/js/dist/prismic.io-1.0.10.min.js:4:3
W20141019-16:24:21.001(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:168:10
W20141019-16:24:21.001(-7)? (STDERR)     at Array.forEach (native)
W20141019-16:24:21.001(-7)? (STDERR)     at Function._.each._.forEach (/Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141019-16:24:21.001(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
W20141019-16:24:25.767(-7)? (STDERR) 
W20141019-16:24:25.769(-7)? (STDERR) /Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141019-16:24:25.770(-7)? (STDERR)                        throw(ex);
W20141019-16:24:25.770(-7)? (STDERR)                              ^
W20141019-16:24:25.770(-7)? (STDERR) ReferenceError: window is not defined
W20141019-16:24:25.770(-7)? (STDERR)     at app/js/dist/prismic.io-1.0.10.min.js:2:6569
W20141019-16:24:25.771(-7)? (STDERR)     at app/js/dist/prismic.io-1.0.10.min.js:4:3
W20141019-16:24:25.771(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:168:10
W20141019-16:24:25.771(-7)? (STDERR)     at Array.forEach (native)
W20141019-16:24:25.771(-7)? (STDERR)     at Function._.each._.forEach (/Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141019-16:24:25.771(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
W20141019-16:24:29.844(-7)? (STDERR) 
W20141019-16:24:29.846(-7)? (STDERR) /Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141019-16:24:29.846(-7)? (STDERR)                        throw(ex);
W20141019-16:24:29.847(-7)? (STDERR)                              ^
W20141019-16:24:29.847(-7)? (STDERR) ReferenceError: window is not defined
W20141019-16:24:29.847(-7)? (STDERR)     at app/js/dist/prismic.io-1.0.10.min.js:2:6569
W20141019-16:24:29.848(-7)? (STDERR)     at app/js/dist/prismic.io-1.0.10.min.js:4:3
W20141019-16:24:29.848(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:168:10
W20141019-16:24:29.848(-7)? (STDERR)     at Array.forEach (native)
W20141019-16:24:29.848(-7)? (STDERR)     at Function._.each._.forEach (/Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141019-16:24:29.848(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
=> Modified -- restarting.
W20141019-16:26:33.472(-7)? (STDERR) 
W20141019-16:26:33.474(-7)? (STDERR) /Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141019-16:26:33.475(-7)? (STDERR)                        throw(ex);
W20141019-16:26:33.475(-7)? (STDERR)                              ^
W20141019-16:26:33.475(-7)? (STDERR) ReferenceError: window is not defined
W20141019-16:26:33.475(-7)? (STDERR)     at app/js/dist/prismic.io-1.0.10.min.js:2:6569
W20141019-16:26:33.476(-7)? (STDERR)     at app/js/dist/prismic.io-1.0.10.min.js:4:3
W20141019-16:26:33.476(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:168:10
W20141019-16:26:33.476(-7)? (STDERR)     at Array.forEach (native)
W20141019-16:26:33.476(-7)? (STDERR)     at Function._.each._.forEach (/Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141019-16:26:33.477(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
=> Modified -- restarting.
W20141019-16:26:40.114(-7)? (STDERR) 
W20141019-16:26:40.116(-7)? (STDERR) /Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141019-16:26:40.116(-7)? (STDERR)                        throw(ex);
W20141019-16:26:40.117(-7)? (STDERR)                              ^
W20141019-16:26:40.117(-7)? (STDERR) ReferenceError: window is not defined
W20141019-16:26:40.117(-7)? (STDERR)     at app/js/dist/prismic.io-1.0.10.min.js:2:6569
W20141019-16:26:40.117(-7)? (STDERR)     at app/js/dist/prismic.io-1.0.10.min.js:4:3
W20141019-16:26:40.118(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:168:10
W20141019-16:26:40.118(-7)? (STDERR)     at Array.forEach (native)
W20141019-16:26:40.118(-7)? (STDERR)     at Function._.each._.forEach (/Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141019-16:26:40.118(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
=> Modified -- restarting.
W20141019-16:26:47.834(-7)? (STDERR) 
W20141019-16:26:47.836(-7)? (STDERR) /Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141019-16:26:47.836(-7)? (STDERR)                        throw(ex);
W20141019-16:26:47.837(-7)? (STDERR)                              ^
W20141019-16:26:47.837(-7)? (STDERR) ReferenceError: window is not defined
W20141019-16:26:47.837(-7)? (STDERR)     at app/doc.js:529:3
W20141019-16:26:47.838(-7)? (STDERR)     at app/doc.js:531:3
W20141019-16:26:47.838(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:168:10
W20141019-16:26:47.838(-7)? (STDERR)     at Array.forEach (native)
W20141019-16:26:47.838(-7)? (STDERR)     at Function._.each._.forEach (/Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141019-16:26:47.839(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
W20141019-16:26:51.795(-7)? (STDERR) 
W20141019-16:26:51.797(-7)? (STDERR) /Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141019-16:26:51.797(-7)? (STDERR)                        throw(ex);
W20141019-16:26:51.798(-7)? (STDERR)                              ^
W20141019-16:26:51.798(-7)? (STDERR) ReferenceError: window is not defined
W20141019-16:26:51.798(-7)? (STDERR)     at app/doc.js:529:3
W20141019-16:26:51.798(-7)? (STDERR)     at app/doc.js:531:3
W20141019-16:26:51.798(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:168:10
W20141019-16:26:51.799(-7)? (STDERR)     at Array.forEach (native)
W20141019-16:26:51.799(-7)? (STDERR)     at Function._.each._.forEach (/Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141019-16:26:51.799(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
W20141019-16:26:55.752(-7)? (STDERR) 
W20141019-16:26:55.754(-7)? (STDERR) /Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141019-16:26:55.755(-7)? (STDERR)                        throw(ex);
W20141019-16:26:55.755(-7)? (STDERR)                              ^
W20141019-16:26:55.755(-7)? (STDERR) ReferenceError: window is not defined
W20141019-16:26:55.755(-7)? (STDERR)     at app/doc.js:529:3
W20141019-16:26:55.756(-7)? (STDERR)     at app/doc.js:531:3
W20141019-16:26:55.756(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:168:10
W20141019-16:26:55.756(-7)? (STDERR)     at Array.forEach (native)
W20141019-16:26:55.756(-7)? (STDERR)     at Function._.each._.forEach (/Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141019-16:26:55.757(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
=> Modified -- restarting.
W20141019-16:59:50.767(-7)? (STDERR) 
W20141019-16:59:50.769(-7)? (STDERR) /Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141019-16:59:50.770(-7)? (STDERR)                        throw(ex);
W20141019-16:59:50.770(-7)? (STDERR)                              ^
W20141019-16:59:50.770(-7)? (STDERR) ReferenceError: window is not defined
W20141019-16:59:50.770(-7)? (STDERR)     at app/doc.js:529:3
W20141019-16:59:50.771(-7)? (STDERR)     at app/doc.js:531:3
W20141019-16:59:50.771(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:168:10
W20141019-16:59:50.771(-7)? (STDERR)     at Array.forEach (native)
W20141019-16:59:50.771(-7)? (STDERR)     at Function._.each._.forEach (/Users/anderskitson/.meteor/packages/meteor-tool/.1.0.34.1q6jdah++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141019-16:59:50.772(-7)? (STDERR)     at /Users/anderskitson/acornmade/mrskitson/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-20 08:56:45

尽管nicolsondsouza这么说,它还是兼容客户端(浏览器)和服务器端(Node.js)。

下面是我们检测Node.js的行(每个文件的末尾):https://github.com/prismicio/javascript-kit/blob/master/src/api.js#L1176

看来测试失败了,我们对全局对象使用“窗口”。我不确定Meteor与Node.js的距离有多近,但这一行需要调整以与Meteor兼容。

另一个特定于平台的代码是XHR,因此也可能存在不兼容问题:https://github.com/prismicio/javascript-kit/blob/master/src/api.js#L26

我们很乐意支持Meteor.js --我们会把它添加到我们的功能愿望列表中,如果你很着急,一个拉请求肯定会有帮助!

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26456822

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档