首页 \ 问答 \ 在require.js中使用Dust(Using Dust in require.js)

在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
更新时间:2024-02-15 13:02

最满意答案

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, especially django.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): ...
  • 这是我的坏事,我只是不正确地使用了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 %} ...
  • 要让注册不发送电子邮件,请将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.

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)