blosxomのプラグインにinterpolate_fancyというものがある。このプラグインは、あまり強力ではないblosxomのテンプレート・システムを強化するもので、ベーシックなif/unless系の分岐が可能になる(他にインストールしているプラグインのサブルーチンを呼べたりもする)。あまりややこしくない正規表現による置換で実装されている。というわけで、簡単なテンプレートシステムとして使うためにJavaScriptに移植してみた。 ベースになったのはprototype.jsの1.5.0_rc1に実装されているTemplateクラス。これのテンプレート変数の書き方をinterpolate_fancyに合わせた<foo/>という形固定にして、条件分岐の正規表現を付け加えるという形でライブラリにしてみた。 使い方は、interpolate-fancy.jsを読み込んでおいた上で、 var
テンプレート関連 JavaScript 最終更新 2008/9/23 日本野望の会−Yabooo.org » Javascript でHTML::Template | Matthias Georgi - Patroon - a Javascript Template Engine google-jstemplate - Google Code Ajaxian » Django Template Language in JavaScript EJS - Embedded JavaScript at Edward Benson JsonML (JSON Markup Language) IT戦記 - JsonML を使う高速テンプレートエンジン「JsonML.Template」 JSLT javascript-based XSLT alternative ZParse - Advanced J
JavaScript function hdoc(){ return arguments.callee.caller.toString().match(/hdoc\(\/\*(([\n\r]|.)+)\*\/\)/m)[1]; } function hdocTest(){ var message = hdoc(/* Peter Piper picked a peck of pickled peppers; A peck of pickled peppers Peter Piper picked. If Peter Piper picked a peck of pickled peppers, Where's the peck of pickled peppers Peter Piper picked? */); alert(message); } 関連リンクCollection & C
概要 JSmartyはPHPのSmartyを模したJavaScriptで動くテンプレートエンジンです。テンプレートAPI部分についてはSmartyを準拠しており、それ以外にも文字列処理が便利になるようにAPIを提供します。 デモ http://www.starmsg.net/samples/JSmarty/plugin.html ダウンロード http://code.google.com/p/jsmarty/downloads/list Hello World!! <script src="JSmarty.js"></script> <script src="JSmarty/Compiler.js"></script> var smarty = new JSmarty(); smarty.assign("foo", "Hello World!!"); smarty.display("str
hinclude.js Tired of regenerating HTML pages from templates? Want more from Web caches? HInclude makes one thing very easy; including other bits of HTML into your Web page, using the browser. See also Gustaf Nilsson Kotte's h-include - it uses Web Components to do the same thing. The Basics Hinclude adds one element to HTML; hx:include. When the browser encounters this element, it will include the
JavaScriptでWikiのフォーマッターを実装してみたものを利用した何かを作るために遊んでいたりいなかったり。 閲覧 (V) 編集 (E) JavaScriptでWikiのフォーマッターを実装してみたものを利用して、Wikiのページっぽくしてみたものです。叩き台。 ---- 1行以上の空行の連続(/\\n\\n+/)をブロックの区切りとみなすという仕様のため、空行がとても重要です。つまり何かにつけて空行を作れということ。 ---- 普通の文章はp要素でマークアップされます。普通の文章とは行頭に特殊な記号が存在しない行のことです。1行を段落とみなして、p要素でくくるということになります。 ---- インライン要素には一部対応しています。 - 強調したい文字列の前後を\'\'で括ると、''em要素''でマークアップされます - さらに強調したい文字列の前後を\'\'\'で括ると、'''s
_ 花見 (00:14) 昨日は会社の花見だったんだけど、ここのところ花粉症がひどいし、いつもの渋谷近辺ではなく上野会場ってことでいまいち土地勘もないし、面倒くさいなーと思いつつも、終わる時間頃を狙ってちょっとだけ顔を出しに行った。けど、場所取り予定地近辺にそれらしい集団は見つからず。携帯に電話してまで合流すると二次会に連れて行かれそうな気がしたんで、上野公園内を散歩して偶然であったら合流しようと思いつつ1時間ほどうろうろしたけど、結局出会えず。まあいいかってことでそのまま帰ってきた。ちなみに桜は1割くらいが咲いている感じ。一分咲きとかではなく、1割の木がほぼ満開になっている、って感じね。 _ JavaScriptでpreg_replace_callback 2 (11:14) 『JavaScriptでpreg_replace_callback』の続き。replaceの第2引数で関数が呼べ
ECMAScript で Wiki っぽいテキストをパーズして HTML DOM ツリーにするパーザです. http://cefiro.homelinux.org/memo/2006-05-10/WikiParser.js ソース http://cefiro.homelinux.org/memo/2006-05-10/test_wiki_parser.html デモ 久しぶりに使ったのでちょっと整理してついでに公開します.コードが腐ってる気がしますが動くみたいなので気にしない方向で. 使い方は以下のような感じにすると pageElement にdiv要素かなにかが入ります. var parser = new WikiParser(document); var pageElement = parser.parse(text);あとはページ内につっこむなり DOM ツリーをトラバースするなり適
XHTMLでCDATA区間を使う。以上。 経緯 HTML4のscriptタグでJavaScriptをちょろっと書く時、中にHTMLタグがあるとダメという話が発端である。例えば、以下のようなのがダメだ。 <script type="text/javascript"> document.write('<p><a href="http://www.hikoboshi.org">hikoboshi.org</a></p>'); </script>ちなみに、ブラウザで動かせば多分動く。(試してないけど。)じゃあ何がダメかというと、HTMLの仕様的に。ちなみにこういう書き方をすると、多分HTML4でもXHTML1でもダメだと思われ。 そんな話をきっかけに、いろいろ調べた。 何故ダメか まずはHTML4のDTDを調べる。(別にstrictを選ばなくても良いんだけどとりあえず。) http://www.w
結構よくある処理だとおもう。 function searchParent(e,f){ return e && (f(e)?e:searchParent(e.parentNode,f)) ; } function searchChild(e,f){ return e && (f(e)?e:(searchChild(e.firstChild,f) || searchChild(e.nextSibling,f))); } searchChild エレメントeの子ツリー内を順番に*1探し、最初に関数f(ノード)がtrueになるものを返す。無ければnull searchParent 親を順番に捜し、関数f(ノード)がtrueになるものを返す。無ければnull tagNameEqual = function(e,tagName){ return e.tagName==tagName; } elemen
JavaScript での変数を使った文字列の作成は何かとめんどくさいですね。prototype.js では 1.5_pre0 から Template という簡易テンプレートとして使えるクラスが加わりました。相変わらずドキュメントはソースと test 嫁なので簡単な使い方を紹介します。 まずは Template となる文字列を new Template で作ります。Template のリテラルは #{}です*1 。 var t = new Template('#{foo}, #{bar}!');次に作成した Template インスタンスの evaluate 関数を呼び出し、引数として Hash(Object) を渡します。 t.evaluate({ foo: 'hello', bar: 'world' }); // hello, world!もしテンプレートを使い回さず、一度限りの文字列
Vivabit is a small London based consultancy established by experienced web professionals that specialises in best-practice web design and development. We don't just do the web, we do it in the best possible way. Whether that's through training, auditing, outsourcing, or full design and build, we can help you to achieve better web sites. Take a look around our newly redesigned web site to see if an
\閉鎖予定のサイトも売れるかも?/ アクセスがないサイトもコンテンツ価値で売れる場合も… ドメインの有効期限を更新してサイト売却にトライしてみましょう
Dollar E: A document.createElement Wrapper2006-03-29 17:11 - ProgrammingFirst, a lead in: I work for Root Markets, as part of the Root Vaults team. The CEO of my company, Seth Goldstein presented at this year's ETech conference, and my team went through a lot of work to get some spiffy new features built for our site to demo at that conference. The primary new feature ( from my perspective ;-) ) w
Over the past 6 months or so Javascript has really gotten a lot of attention. I can’t name a web application released in the previous months (although I’m sure there are a few) that doesn’t use Javascript to provide an enhanced experience for users. I wanted a way to facilitate that interaction that doesn’t involve me repeating myself over and over wiring and rewiring event ovservers to a document
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く