所以,假设我正在存储<div>{{name}}</div>
并存储<div>{{age}}</div>
在我的数据库中.然后我想获取第一个HTML字符串并在模板中呈现它 - {{> template1}}
它只是呈现带有{{name}}
把手的第一个字符串.然后我想给出新生成的模板/ html数据,这样它就可以用name
数据库中的实际来填充把手,这样我们就可以得到<div>John</div>
.我试过了
<template name="firstTemplate">
{{#with dataGetter}}
{{> template1}}
{{/with}}
</template>
Run Code Online (Sandbox Code Playgroud)
其中template1定义为
<template name="template1">
{{{templateInfo}}}
</template>
Run Code Online (Sandbox Code Playgroud)
而templateInfo是一个帮助器,它从数据库中返回带有把手的上述html字符串.
dataGetter就是这个(只是一个例子,我正在使用不同命名的集合)
Template.firstTemplate.dataGetter = function() {
return Users.findOne({_id: Session.get("userID")});
}
Run Code Online (Sandbox Code Playgroud)
我无法填充{{name}}.我尝试了几种不同的方法,但似乎Meteor不明白字符串中的把手需要用数据进行评估.我在0.7.0所以没有Blaze,由于我正在使用的其他软件包,我目前无法升级,他们还没有支持0.8+版本.关于如何让它工作的任何想法都非常感谢.
我正在尝试使用CryptoJS 3.1.5解密使用openssl加密的文件.
如果我使用CryptoJS进行加密和解密,一切正常,对于shell中的OpenSSL也是如此,但是当我尝试将CryptoJS与OpenSSL混合时,一切都会出错.
使用以下命令创建文件:
openssl enc -aes-256-cbc -in file.txt -out file.enc -k password
Run Code Online (Sandbox Code Playgroud)
我试着像这样解密:
fs.readFile('file.enc', function(err, data) {
var decrypted = CryptoJS.AES.decrypt(
data.toString(),
"password",
{ mode : CryptoJS.mode.CBC }
);
console.log(decrypted.toString(CryptoJS.enc.Utf8));
});
// Give me this err: Uncaught Error: Malformed UTF-8 data
Run Code Online (Sandbox Code Playgroud)
而在另一方面,我做:
fs.readFile('file.txt', function(err, data) {
var encrypted = CryptoJS.AES.encrypt(
data.toString(),
"password",
{ mode : CryptoJS.mode.CBC });
fs.writeFile('file.enc', encrypted);
});
Run Code Online (Sandbox Code Playgroud)
然后在壳牌:
openssl enc -d -aes-256-cbc -in file.enc -out file2.txt -k password
// Give me this err: bad …
Run Code Online (Sandbox Code Playgroud) 我曾经$.browser.webkit
检测过我的浏览器是否为Safari/Chrome,现在false
使用Chrome时此检查是否会恢复?
cryptojs ×1
encryption ×1
jquery ×1
meteor ×1
meteor-blaze ×1
node.js ×1
openssl ×1
spacebars ×1
templates ×1