Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kjunichi
Last active December 19, 2015 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjunichi/5972536 to your computer and use it in GitHub Desktop.
Save kjunichi/5972536 to your computer and use it in GitHub Desktop.
expressの使い方メモ

GETのパラメータを受け取るには

req.query.foo
req.query.bar

POSTのパラメータを受け取るには

req.body以下にjsonが格納

req.body.foo
req.body.bar

XmlHttpRequestでアクセスされたかを判定するには

if(req.xhr) {
}

関連

POSTでパラメータを取得するには

req.body.paramname

hogan.jsをクライアントサイドで使う

基本的にはクライアント側からPOSTするスタイルでやってみる場合は、こういったクライアントサイドで利用できる テンプレートを利用するのだろう。

テンプレート

<script type="text/template" id="tmpl">
    <table>
        {{#partial}}
        <tr>
            <td>{{hoge}}</td>
        </tr>
        {{/partial}}
    </table>
</script>

JavaScript側での処理

var myTemplate = Hogan.compile(document.getElementById("tmpl").innerHTML);

関連Gist

アクセス解析タグ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment