Tag: 帕格

如何访问模态视图中的对象

我有一个游戏里面的canvas标签。 当我点击一个游戏实体时,我想打开一个模式,并在视图中,能够访问被点击的对象的属性。 这是我点击游戏实体时调用的函数: function pause(player) { $('myModal').modal(); } 以下是模态渲染的视图: #myModal.modal.fade(tabindex='-1', role='dialog', aria labelledby='myModalLabel', aria-hidden='true') .modal-dialog .modal-content .modal-header button.close(type='button', data-dismiss='modal', aria-label='Close') span(aria-hidden='true') × h4#myModalLabel.modal-title .modal-body h5 Object Properties ul.list-group -// List all properties of the player object here form .form-group label.control-label(for='script-text') Text: input#script-text.form-control(type='text') .modal-footer button.btn.btn-primary.pull-left(type='button') Submit button.btn.btn-default(type='button', data-dismiss='modal') Cancel 如何从视图中访问player对象? 我确信有一个简单的答案,但我似乎无法弄清楚。

meteorJS Jade模板不能按预期工作

我试过这个包https://github.com/matteodem/meteor-easy-search/使用这个示例代码很容易search <template name="searchBox"> {{> esInput index="players" placeholder="Search…" }} <ul> {{#esEach index="players"}} <li>Name of the player: {{name}}</li> {{/esEach}} </ul> </template> 并将其转换为玉石 template(name="searchBox") +esInput index="players" placeholder="Search…" ul esEach index="players" li Name of the player: {{name}} 如果我使用html格式的search工作,但是当我使用玉石格式没有错误,但search将不会显示。 我把html转换成了jade吗? 任何想法为什么玉不起作用?

吞噬水龙头进入无限循环

我试图获取当前的文件名在globstream内,以便我可以将它传递给玉来正确命名我的模板。 通常它看起来像: gulp.task('templatesjs', function() { gulp.src('src/templates/*.jade') .pipe(jade({ client: true, name:"filenamehere" })) .pipe(gulp.dest('build/templates')) }); 我在网上find的唯一答案是通过使用gulp-tap来提取stream中的文件名: gulp.task('templatesjs', function() { gulp.src('src/templates/*.jade') .pipe(tap(function(file, t) { var filename = file.relative.split('.')[0]; return t.through(jade, [{client:true, name:filename}]); })) .pipe(gulp.dest('build/templates')) }); 但是由于某种原因,这个进入了一个无限循环。 如果glob匹配index.jade,例如第一个迭代的file.relative被设置为index.jade,但是它会在file.relative被设置为index.js的无限循环中被捕获,并且jade编译器崩溃试图编译index.js文件。 我知道这是因为,如果我省略客户端:true选项,file.relative是在第一次迭代index.jade和所有迭代后的index.html。 这当然不会崩溃,但会陷入一个无限循环,编译index.html到index.html。 我的解决scheme是检查文件的扩展名,只通过玉pipe道,如果我在一个包含玉文件的迭代。 这解决了无限循环,但它是sl and,它复制一个玉文件到我的build立目录(不是一个巨大的交易)。 它也只对第一个文件起作用,对所有文件起作用后都得到第一个文件的名字。 我知道我做错了什么,但我不知道是什么。 gulp.task('templatesjs', function() { gulp.src('src/templates/*.jade') .pipe(tap(function(file, t) { sourcefile = file.relative; filename = sourcefile.split('.')[0] if(sourcefile.split('.')[sourcefile.split('.').length-1]!='js') […]

在“for article,slug in public.articles._data”什么是“slug”? 有没有办法使用嵌套数组?

我试验了一个NodeJS静态博客生成器HarpJS。 在教程中有这样的元数据的例子: for article, slug in public.articles._data a(href="/articles/#{ slug }") h2= article.title 和_data.json文件: { "hello-world": { <– available everywhere as public.articles._data "title": "Hello World.", "date": "2013-02-28" }, "hello-brazil": { "title": "Hello Brazil.", "date": "2013-03-04" } } 如果我理解for article权利拿到每一个高层次的对象,我们可以用article.title或者article.title来得到标题。 但是什么是slug ?? 它是Jade / HarpJs中的预定义variables吗? 如果是这样,还有其他的,还是我认为这个概念错了? 我找不到关于这个主题的任何信息,如果有一篇好文章,我将不胜感激。 谢谢。 正如@Brennan在评论中所言,第二个参数可能是一个索引。 variablesarticle和slug简单replace和重命名certificate了这一点。 但还有一个问题。 请考虑这个例子: { "hello-world": { "title": "Hello […]

Jade:从主页以外的任何地方修改<head>

更新: 我也把这个问题发布到了Jade GitHub仓库。 我也把它放在这里,以供将来(循环)参考: https : //github.com/jadejs/jade/issues/1943 原文: 在一个默认的节点+ express + jade应用程序中,我正在尝试构build一些常用的可重用组件(菜单,页脚…),这些组件可以包含在一些页面中。 我试图从块或包含文件中添加对.css或.js文件的引用时被卡住了。 我想这样做,因为如果我不需要它们,我不想包含所有的样式和脚本。 文件夹结构是这样的: 根 上市 JavaScript的 main.js menu.js 样式表 的main.css menu.css 意见 共享 layout.jade menu.jade footer.jade index.jade layout.jade文件: doctype html html head title= title link(rel="stylesheet", href="stylesheets/main.css") script(src="javascripts/main.js") body block content index.jade文件: extends shared/layout block content h1= title p Welcome to #{title} 在menu.jade中有一些代码需要menu.css和menu.js文件。 现在我只需要使用menu.jade文件,就可以将这些文件添加到页面的<head>中。 […]

玉中的variables中的长string

我正在编写一个支持多种语言的Web应用程序。 我正在做的是将string传递给翻译类,它将执行翻译。 现在,我需要在我的模板中添加一些长文本,我想在多行上提供可读性。 – var longText = 'Some really long text … '; // … p #{i18n.tr(longText)} 我想做类似的事情 – var longText = 'Some text ' + – 'some other text' // … p #{i18n.tr(longText)} 不幸的是,玉不喜欢那样。 是否有可能在玉的多行string?

自动caching清除静态构build与npm运行良好?

我使用npm作为我的构build工具,通过为我需要的任务使用各种命令填充scripts字段 。 除了一个小的细节之外,我对设置感到满意:在为生产构build时,我希望在<link>标记中引用CSS文件,并在<script>标记中引用JS文件以更新caching清除即通过将?random_string附加到文件名或类似的内容来进行修改)。 我正在使用jade ,以防万一有办法这样做,我错过了。 我不介意解决scheme是否破坏每个文件,即使它们自上次构build之后没有更改。 我所关心的是,它并不要求我在网站上添加复杂的代码(就像一个function,这是它的唯一目的)。 它应该最好是一个外部命令。 到目前为止,我还没有find一个可以接受的解决scheme。 我几乎要诉诸于正则expression式,但真的会有一个更强大的解决scheme。

当使用玉的“漂亮”选项时,如何防止单个区块中的元素之间的空格?

一般来说,我喜欢漂亮的select。 我喜欢我的HTML是可读的, pretty帮助。 但是有时候会阻碍。 例如。 x.do-not-care-about-spaces It can go either way here. y.please-no-spaces These y.please-no-spaces Should y.please-no-spaces Touch 我想看到的是: <x class="do-not-care-about-spaces">It can go either way here.</x> <y class="please-no-spaces">These</y><y class="please-no-spaces">Should</y><y class="please-no-spaces">Touch</y> 但是我所看到的是 <x class="do-not-care-about-spaces">It can go either way here.</x> <y class="please-no-spaces">These</y> <y class="please-no-spaces">Should</y> <y class="please-no-spaces">Touch</y> 我知道有几种方法可以解决这个问题(用css,把html放在jade文件中),但是我希望的是用jade的方式来做到这一点。 编辑:更新示例标签,而不是divs的例子。 我特别要问的是如何控制jade HTML输出中的DOM节点之间的空间,而不是渲染的网页上的元素之间的视觉空间。

jade文件中显示节点服务器中的警告

我有很多&nbsp; s'在我的玉文件中,当我运行节点服务器时显示为警告: Warning: missing space before text for line 210 of jade file "C:\Users\XX\Documents\GitHub\XXX\XX\registerPage.jade" 这个警告显示在哪里有一个&nbsp; ,我不想要它,因为从服务器生成的日志文件充满了这些警告。

其他网站的快递方

我有一个基本的Express应用程序,其中一个function使用nodejs请求,并使用select器使用一些div。 之后,我想用玉来渲染。 var express = require('express'); var voc = require('vocabulaire'); var async = require('async'); var router = express.Router(); router.get('/', function (req, res) { res.render('index', {title: 'Espace de la diffusion'}); }); var result; router.get('/search/:mot', function (req, res) { async.series([ function () { result = main(['conj', req.params.mot]); console.log('in 1'); }, function () { res.render('index', {title: 'Espace de […]