点击查看html编辑器说明文档

haml-coffeeedit icon

|
|
Fork(复制)
|
|
作者:
lynn-ssk
提交反馈
嵌入
设置
下载
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ...
展开
</head>
<body>
            
            <!-- <script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/coffee-script/1.7.1/coffee-script.min.js" type="application/javascript"></script> -->

<!-- <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/coffee-script/1.12.7/coffee-script.js" type="application/javascript"></script> -->
<script src="https://uovol-resource.oss-cn-shenzhen.aliyuncs.com/js/coffee-script@1.12.7.js"></script>
<!-- <script src="https://cdn.bootcdn.net/ajax/libs/coffee-script/1.12.7/coffee-script.min.js"></script> -->

<script src="https://uovol-resource.oss-cn-shenzhen.aliyuncs.com/js/hamlcoffee.js" type="application/javascript"></script>

        
</body>
CSS
格式化
            
            
        
JS
格式化
            
            const Compiler = require('./haml-coffee');
let hamlc = require("/hamlc.coffee");
let item = { title: 'Haml Coffee rocks!'}
let hamlStr = `

-8.times do
 %div
  %label
`
// console.log(exports);
const compiler = new Compiler();
compiler.parse(hamlStr);

let fn_pre = compiler.precompile()

console.log('fn_pre:', fn_pre)

let fn_str = CoffeeScript.compile(fn_pre, {
  bare: true
});

console.log('fn_str:', fn_str)

// let template = new Function(fn_str);
let template = new Function(`
var $o;

$o = [];
Number.prototype.times = function(fn) {
  var i, ref;
  if (this.valueOf()) {
    for (i = 1, ref = this.valueOf(); 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--) {
      fn();
    }
  }
};


(8).times(() => $o.push("<div> <label></label> </div>"));

return $o.join("");
`);

console.log("template", template.toString())

let result = template()
console.log(result)
//////////////
tmpl = hamlc.compile(hamlStr)
html = tmpl()

// console.log(html)

        
预览
控制台
清空