唐突に、PHP用のテンプレートエンジンを作ってみる。 方針: ふつうのPHPファイルをテンプレートとして使う。 <?php echo $var; ?> は面倒なので #{$var} と書けるようにする。 <?php echo htmlspecialchars($var); ?> はもっと面倒なので %{$var} と書けるようにする。 ついでにXML宣言も <<?php ?>?xml ... に自動置換する。【追記】レイアウト機能を追加してみた コード: <?php /* * SixtyLinesTemplate.php - 60行しかないけどSmartyより速いテンプレートエンジン * * 使い方: * require_once('SixtyLinesTemplate.php'); * $TEMPLATE_DIR = 'templates'; // 省略可、パーミッションに注意 * $c
追記: 指摘により、UIオブジェクト型を追加した(thx @kanreisa)。 クライアントサイドJavaScriptでのビューの作り方を大別すると、3つ4つある。 DOM操作型 テンプレートエンジン型 UIオブジェクト型 データバインディング型 ここでいうビューの作り方とは、有り体にいうとJavaScriptからどうやってDOM要素を生成したりするかどうか。イベントリスナーの登録とかも含む。 DOM操作型 昔ながらのやり方。jQueryとか使って直接DOM操作してビューを作る。 // 例えば、<div class='hoge'>fugafuga</div> みたいなDOMを表示する var myView = $("<div class='hoge'/>"); myView.text('fugafuga'); // body以下に挿入 $(body).append(myView); 長所
GoFデザインパターンの一覧表と,活用のためのコメント,および入門者が独学するためのリンク集(サンプルコード付き)。 入門者の独学を支援するために,このページのURLを提示して熟読させ,各パターンを短時間で効率よく学んでもらう。 デザインパターンはプログラマの常識だ。 Java使いかどうかは問わない。 にも関わらず,入門書を買ったまま,途中で挫折する人が多い。 挫折の原因は,パターンの数が23もあって,多いからだろう。 全パターンをすんなり覚えてもらうためには,各パターンごとに 「要するにこういう目的のパターンなんだ。」 「10文字で表現すると,パターンの意味はこうなんだ。」 という要点・本質を,短いコメントで伝えれば助けになるだろう。 こういった学習を通して,Java言語の「設計思想」も併せて感じ取ってゆけるはず。 全パターンの一覧表(要約コメント付き) 全パターンについて,10文字以内
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く