使用Jade显示输入值内的数据 [英] Display data inside input value using Jade

查看:116
本文介绍了使用Jade显示输入值内的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对翡翠来说相当新鲜,我想要显示一些输出的数据作为文本输入。像这样:

  input(type =text,name =date,value =THISRIGHTHURR)

但只有值需要是 viewpost.date 。我尝试了多种方式,而且似乎没有办法:

  input(type =text,name =date value = viewpost.date)//不工作
input(type =text,name =date,value =。= viewpost.date)//不工作
input type =text,name =date,value =。= viewpost.date)//不工作

我当然可以通过执行类似



<$的方式让它在输入之外工作p $ p> 每个帖子,我在viewpost
h1。= post.date

我应该在输入中循环使用吗?这是JS(使用Node和Express)输出我的 viewpost 变量。

  // render show post view 
exports.viewpost = function(db){
return function(req,res){
var id = req.params.id;

collection.find({_id:new BSON.ObjectID(id)},function(err,data){
res.render(viewpost,{
viewpost:data
});
});
};
};


解决方案

您可以尝试用#{} 输出:



input(type =text,name =date ,value =#{viewpost.date})


I'm fairly new to Jade and am wanting to display some outputted data as the value value of a text input. Like this:

input(type="text", name="date", value="THISRIGHTHURR")

But only the value needs to be viewpost.date. I've tried multiple ways and none seem to work:

input(type="text", name="date", value=viewpost.date) // doesn't work
input(type="text", name="date", value=.=viewpost.date) // doesn't work
input(type="text", name="date", value=".=viewpost.date") // doesn't work

I of course can get it to work outside of an input by doing something like

each post, i in viewpost
  h1.=post.date

Am I supposed to loop through in the input somehow too? This is the JS (using Node and Express) that's outputting my viewpost variable.

// render show post view
exports.viewpost = function(db) {
    return function(req, res) {
        var id = req.params.id;

        collection.find({ "_id": new BSON.ObjectID(id) }, function (err, data) {
            res.render("viewpost", {
                "viewpost" : data
            });
        });
    };
};

解决方案

You can try enclosing the variable in #{} to output it:

input(type="text", name="date", value="#{viewpost.date}")

这篇关于使用Jade显示输入值内的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆