问题标签 [block]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
5 回答
61099 浏览

ruby-on-rails - Rails 用块渲染部分

我正在尝试重新使用我编写的提供面板样式的 html 组件。就像是:

所以我看到渲染需要一个块。我想我可以做这样的事情:

我想做类似的事情:

不幸的是,这不适用于此错误:

所以它显然不喜欢=带有块的,但如果我删除它,那么它就不会输出任何东西。

有谁知道如何做我想要在这里实现的目标?我想在我网站的许多地方重复使用这个面板 html。

0 投票
10 回答
148089 浏览

ruby - Blocks and yields in Ruby

I am trying to understand blocks and yield and how they work in Ruby.

How is yield used? Many of the Rails applications I've looked at use yield in a weird way.

Can someone explain to me or show me where to go to understand them?

0 投票
1 回答
891 浏览

scope - GCD / block scoping in Objective-C++

I'm using GCD to speed up some calculations in a few C++ templates I'm working on. I've already done it successfully for several functions, but now I'm trying to get it to work for a member function and I've encountered this weird scoping problem. The code looks something like this:

I understand that there might be some scoping issues when I'm accessing array elements like a._c1m[imodes2+jmodes+k], for instance (i.e. I might need to throw some pointers in there or something), but here's the real problem: when I declare NSIntegers like mi or just the looping indices j and k, for instance, the compiler gives me a ton of errors like the following:

'NSInteger op::mi' is not a static member of 'class op'

This has only happened to me for this member function--I implemented almost exactly the same technique on a friend function (with the same NSInteger declarations in the scope of the block) and it worked just fine.

The only fix I've been able to think up is declaring all of my looping variables outside the block as pointers and then dereferencing them in the scope of the block, but this strikes me as kind of a hack. Anybody know what's going on here?

Thanks in advance for your help!

0 投票
3 回答
42427 浏览

ruby-on-rails - 如何在 html.erb 文件中运行多行 Ruby

我正在使用 Ruby on Rails,需要在我的一个 html.erb 文件中运行一段 Ruby 代码。我这样做是不是这样:

或像这样:

谢谢阅读。

0 投票
2 回答
6527 浏览

django - Django 模板块标签

像这样的不同块标签存在多少?

换句话说,如果我有一个父模板和带有多个块标签的子模板。如果不是通过不同的块标签名称,Django 怎么知道在哪里插入?

或者我可以像这样自定义:

0 投票
2 回答
2492 浏览

c# - 以编程方式阻止网站

该程序有一个黑名单,它包含一个站点列表。当用户在 IE(Firefox、Opera、Chrome)中打开该站点时,他应该得到一个错误。(例如 404)。我能怎么做?建议不要写入文件 HOSTS。语言 C#。

0 投票
4 回答
3040 浏览

magento - 通过 local.xml 文件删除嵌套在块中的块

我正在尝试使用我的 local.xml 文件(我在其中对布局进行所有更新)来删除嵌套在另一个块中的块。我可以通过 <remove> 标记或使用 unsetChild 方法轻松删除块,但我似乎无法删除嵌套在另一个块中的块。

这是我要删除的代码行(位于 customer.xml 文件中)。特别是,它是名为“customer_account_dashboard_newsletter”的块

我意识到这现在不起作用,但这是我的起点(位于我的 local.xml 文件中):

有什么想法吗?谢谢你。

0 投票
3 回答
279 浏览

python - 块内块

我在模板中显示嵌套块时遇到问题。

例如。

我收到“无效的块标签:'endfor'”错误。

有任何想法吗?

0 投票
2 回答
4384 浏览

facebook - 越过 Facebook 的 iframe 块

好吧,在 Facebook 上,他们似乎有一个阻止你加载iframe他们网站的块。

当您这样做时,他们会锁定其网站示例的完整功能。

我只是想知道是否有人知道您如何绕过这个?

0 投票
4 回答
728 浏览

block - 我们是否变得过于依赖谷歌?

在互联网不存在的美好时光里,程序员有以下危险的工具:

  1. 图书

  2. 教师

对,就是那样!只有两个资源。在搜索示例代码时,他们要么必须从同事那里复制代码,要么只是阅读几本书,直到找到他们需要的代码。这是一个非常漫长而累人的过程。当程序员找不到他们需要的代码时,他们只需要自己编写代码(逻辑)。例如,如果您正在开发一个聊天程序,如何使两台计算机相互通信。如果程序员买不起书或老师,这种项目可能需要几个月的时间。

现在随着谷歌的出现,我可以搜索“Java 聊天程序”,然后整个代码就会出现,我可以添加我需要的内容并推销该软件。每个人都同意我的观点,这实际上不是编程吗?并且程序员实际上并不是真正的程序员,因为谷歌给了他们所有的东西。即使我被困在代码上,事实上,我总是在谷歌上搜索,答案就出来了。而且,如果不是谷歌的话,我需要几个月的时间才能编写出一段特定的代码。这真的使我或其他任何人成为真正的程序员吗?我已经开始 iphone 开发,我发现如果我不使用谷歌,而只是使用书籍,它不可能做出任何事情。我很感激即使您可以访问谷歌,你仍然需要调整/更改代码以适应你需要做的事情——我可以通过这样做来创造任何东西。感谢所有评论。你看,我真正想从你们所有程序员那里听到的是“是的,Qessar,我们非常依赖谷歌,我们搜索最基本的东西,你不应该为此感到内疚,因为我们不不!而且如果不是谷歌,我们需要 3 个月才能完成的项目现在需要 3 周才能完成,因为我们需要的代码只是从论坛和谷歌扔给我们的”。

每个人都同意我的观点吗,除了作为一名程序员之外,它似乎现在更多的是关于在谷歌中使用正确的关键字来寻找你想要的任何东西(即“将字符串转换为整数 C#”等)并且能够买得起好老师或平装书(现在你可以在线购买电子书)。

欢迎所有评论。