jade-client-connect

2019-10-09 admin

jade-client-connect是什么

什么是jade-client-connect,Jade Client Connect - A compiler to help use templates on a web client

jade-client-connect使用教程帮助文档

Jade Client Connect

This is a piece of Middleware for the connect framework. It can be plugged into Connect servers or Express servers and expose a URL to the client which will have as a javascript file all of the compiled templates.

How to use

npm install jade-client-connect

or clone the git repository locally & run ‘npm install -d’

In your connect server file

app = require('connect').createServer();
app.use(require('./jade-client-connect/')(__dirname + "/views"));

On the client

<!-- Make sure to include the runtime from Jade's source here, see jade for details -->
<!-- <script src="/scripts/runtime.js"></script> -->
<script src="/scripts/templates.js"></script>
<script>
  // Assuming you have a file named content.jade in the views folder
  var html = tpl.content({ title: "Hello World" });
</script

Defaults & Options

var options = {
  ns : 'tpl'
}
app.use(require('./jade-client-connect/')(__dirname+"/views", options));

The src option is the folder that contains all of the jade templates. Each of the files inside this directory will be compiled as a javascript jade template in the ns client namespace. By default the namespace is tpl so all teplates will be accessed by calling something like tpl.footer(). Only one file will be sent back to the client.

Running Tests & Compiling Source

cake build
cake test

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-76900.html

文章标题:jade-client-connect

回到顶部