在require.js中使用Dust(Using Dust in require.js)
很抱歉发布另一个“你如何使用* with require.js”的问题,但我似乎无法让dust.js在我的require项目中工作。 我已经用Google搜索了,其他人肯定会因为需要而尘埃落定。 我的配置相当标准,但我找不到任何人遇到与我看到的问题相同的问题。
我从这里使用的是版本的尘埃0.3.0: https : //github.com/akdubya/dustjs/blob/master/dist/dust-core-0.3.0.js
这是我的配置:
requirejs.config({ //exceptions: paths: { 'jquery' : 'lib/require-jquery.1.9.1', 'jquery.mockjax' : 'lib/jquery.mockjax.1.5.1', 'dust' : 'lib/dust.0.3.0' }, //Shims are required for jQuery plugins. shim: { 'jquery.mockjax': { deps: ['jquery'], exports: 'jQuery.fn.mockjax' }, 'dust': { exports: 'dust' } }
});
这就是我在模块中包含灰尘的方法:
define( function( require ) { var _d = require('dust') , _template1 = require('text!template/basicmodal.html'); function render(key,callback){ var compiled = _d.compile("Hello {name}!", key); _d.loadSource(compiled); _d.render(key, {name: "Fred"}, callback); } return { render : render,
如果我在渲染函数中设置断点,我可以看到_d确实包含尘埃对象,但由于某种原因,它没有所有的方法。 特别是它的'compile'方法丢失了,导致我的代码失败。
有没有更好地了解尘埃的人知道我在这里可能会缺少什么吗?
Sorry for posting another "how do you use * with require.js" question, but I can't seem to get dust.js working in my require project. I've googled around and other people are definitely getting dust to work with require. My configuration is fairly standard, but I can't find anyone having the same problems as I'm seeing.
I'm using the version of dust 0.3.0 from here: https://github.com/akdubya/dustjs/blob/master/dist/dust-core-0.3.0.js
here is my config:
requirejs.config({ //exceptions: paths: { 'jquery' : 'lib/require-jquery.1.9.1', 'jquery.mockjax' : 'lib/jquery.mockjax.1.5.1', 'dust' : 'lib/dust.0.3.0' }, //Shims are required for jQuery plugins. shim: { 'jquery.mockjax': { deps: ['jquery'], exports: 'jQuery.fn.mockjax' }, 'dust': { exports: 'dust' } }
});
this is how I include dust in my module:
define( function( require ) { var _d = require('dust') , _template1 = require('text!template/basicmodal.html'); function render(key,callback){ var compiled = _d.compile("Hello {name}!", key); _d.loadSource(compiled); _d.render(key, {name: "Fred"}, callback); } return { render : render,
If I set a breakpoint within the render function I can see that _d does contain the dust object, but for some reason it doesn't have all its methods. In particular its 'compile' method is missing which causes my code to fail.
Does anyone with a better understanding of dust know what I might be missing here?
原文:https://stackoverflow.com/questions/17339388
最满意答案
django-registration向用户发送电子邮件,例如,当他或她注册时。 过程如下(如果这是你的问题...)*:
用户填写并提交了注册表......
在
views.py:187
new_user = backend.register(request, **form.cleaned_data)
例如,
backends/default/__init__.py:78
new_user = RegistrationProfile.objects.create_inactive_user(username, email, password, site)
在
models.py:79
if send_email: registration_profile.send_activation_email(site)
然后在
models.py:207
def send_activation_email(self, site): ... self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
最后一个方法调用进入
django.contrib.auth
,尤其是django.contrib.auth.models.User.email_user
PS此外,它很粗糙,但一般来说,搜索代码库,例如使用
grep
或类似的工具可以显示这样的事情。* changeset 073835a4269f
django-registration sends an email to the user, e.g. when he or she registers. The process is as follows (if this was your question ...)*:
The user has filled out and submitted the registration form ...
in
views.py:187
new_user = backend.register(request, **form.cleaned_data)
in e.g.
backends/default/__init__.py:78
new_user = RegistrationProfile.objects.create_inactive_user(username, email, password, site)
in
models.py:79
if send_email: registration_profile.send_activation_email(site)
and then in
models.py:207
def send_activation_email(self, site): ... self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
The last method call goes into
django.contrib.auth
, especiallydjango.contrib.auth.models.User.email_user
P.S. Also, it's crude, but in general a search on the codebase, e.g. with
grep
or similar tools can show you things like this.*changeset 073835a4269f
相关问答
更多-
django-registration在内部使用以下代码来处理发送电子邮件: send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [self.user.email]) 如果你想工作,你必须在settings.py中指定值DEFAULT_FROM_EMAIL。 另请注意以下几点: 使用EMAIL_HOST和EMAIL_PORT设置中指定的SMTP主机和端口发送邮件。 EMAIL_HOST_USER和EMAIL_HOST_PASSWORD设置(如果 ...
-
django-registration向用户发送电子邮件,例如,当他或她注册时。 过程如下(如果这是你的问题...)*: 用户填写并提交了注册表...... 在views.py:187 new_user = backend.register(request, **form.cleaned_data) 例如, backends/default/__init__.py:78 new_user = RegistrationProfile.objects.create_inactive_user(username ...
-
这是如何做到的(正确的方式)。 创建registration.forms.RegistrationForm的子类: class EmailDomainFilterRegistrationForm(RegistrationForm): def clean_email(self): submitted_data = self.cleaned_data['email'] if not ALLOWED_DOMAINS: # If we allow any domain ...
-
首先根据供应商视图创建您自己的视图并覆盖您所需的方法: from registration.backends.hmac.views import RegistrationView class CustomRegistrationView(RegistrationView): def get_email_context(self, user): context = super().get_email_context(user) return RequestConte ...
-
尝试按照有关指定身份验证后端的文档中的说明设置AUTHENTICATION_BACKENDS设置 然后,在您的register方法中,使用django.contrib.auth.authenticate方法登录(请参阅如何记录用户 ),而不是手动实例化后端实例。 该authenticate方法应该注意设置用户backend属性,因此不应该出现任何错误。 Try setting the AUTHENTICATION_BACKENDS setting as described in the docs on sp ...
-
使用自定义模型,例如: from registration.models import RegistrationProfile class CustomRegistrationProfile(RegistrationProfile): """ Custom registration profile """ class Meta: proxy = True def send_activation_email(self, site): ...
-
django-registration:无法翻译电子邮件和主题(django-registration: Cannot translate email and subject)[2023-09-07]
这是我的坏事,我只是不正确地使用了makemessages 。 默认情况下,它只处理.html文件 。 在我的情况下 django-admin.py makemessages -a -e html,txt 完成所有工作。 至于变量, {% blocktrans %}{% endblocktrans %}无法处理对象内的变量,因此我们必须在翻译之前检索它们: {% blocktrans with site.name as site_name and site.domain as site_domain %} ... -
django-registration with paypal integration(django-registration with paypal integration)[2023-10-27]
要让注册不发送电子邮件,请将send_email=False传递给您视图中的RegistrationManager.create_inactive_user调用以注册用户。 创建用户后,您可能希望创建一个带有paypal按钮的登录页面进行付款。 指示用户单击付款按钮进行付款。 通常我会在付款按钮的custom字段中发送user.id 然后,在django-paypal ,使用IPN信号处理程序根据IPN查询的custom字段中的user.id激活用户。 您可能希望此时发送修改后的注册电子邮件,欢迎用户访问您 ... -
从django-1.5的发行说明 这样做的结果是,如果您未在模板中使用{%load url from future%},则需要将{%url myview%}等标记更改为{%url“myview”%}。 如果你使用来自未来%的{%load url},你可以在Django 1.5下删除该行 这意味着,在降级期间, {% url "myview" %} 应该 {% url myview %} 这是错误的原因。 From release notes of django-1.5 The upshot of th ...
-
你忘了添加 EMAIL_HOST = 'smtp.mysite.com' 发送电子邮件。 You forget to add EMAIL_HOST = 'smtp.mysite.com' to send email.