diff --git a/doc/guide/ko/template_engine_wrappers.md b/doc/guide/ko/template_engine_wrappers.md new file mode 100644 index 00000000..6fc032f2 --- /dev/null +++ b/doc/guide/ko/template_engine_wrappers.md @@ -0,0 +1,199 @@ + +# ÅÛÇø´ ¿£Áø ·¡ÆÛ + + + + +³ª¸¸ÀÇ ÅÛÇø´ ¿£Áø ·¡ÆÛ¸¦ ¸¸µå´Â °ÍÀº ½±½À´Ï´Ù. ÀÌ Â©¸·ÇÑ Æ©Å丮¾ó¿¡¼­´Â, [ss-hogan](https://github.com/socketstream/ss-hogan)À» »ìÆìº¼ °ÍÀÔ´Ï´Ù. ss-hoganÀº Æ®À§ÅÍÀÇ [Hogan library](http://twitter.github.com/hogan.js/)¿ë ·¡ÆÛÀÔ´Ï´Ù. + + + +[ss-hogan repository]([ss-hogan](https://github.com/socketstream/ss-hogan)) À̰÷¿¡ º¸¸é ÅÛÇø´ ¿£Áø ·¡ÆÛÀÇ ÆÄÀÏ ±¸Á¶¸¦ º¼ ¼ö ÀÖ½À´Ï´Ù. ÇÙ½É ÆÄÀÏÀÎ `engine.js`À» ÇÔ²² »ìÆì º¾½Ã´Ù: + + + +```ÀÚ¹Ù½ºÅ©¸³Æ® +/* engine.js */ + +// ¼ÒÄϽºÆ®¸² 0.3 ¿ë È£°Ç ÅÛÇø´ ¿£Áø ·¡ÆÛ + + +var fs = require('fs'), + path = require('path'), + hogan = require('hogan.js'); + +exports.init = function(ss, config) { + + // Ŭ¶óÀÌ¾ðÆ® Ãø¿¡ Hogan VMÀ» º¸³½´Ù. + var clientCode = fs.readFileSync(path.join(__dirname, 'client.js'), 'utf8'); + ss.client.send('lib', 'hogan-template', clientCode); + + return { + + name: 'Hogan', + + // óÀ½À¸·Î Hogan ÅÛÇø´ÀÌ È£ÃâµÇ¾úÀ» ¶§, Äڵ带 »ç¿ëÇÒ ¼ö ÀÖ°Ô ¿­¾îÁØ´Ù. + prefix: function() { + return ''; + }, + + // ÅÛÇø´À» ÇÔ¼ö·Î ÄÄÆÄÀÏÇØÁØ ÈÄ, À̰ÍÀ» ss.tmpl¿¡ Ãß°¡½ÃÄÑÁØ´Ù. + process: function(template, path, id) { + + var compiledTemplate; + + try { + compiledTemplate = hogan.compile(template, {asString: true}); + } catch (e) { + var message = '! Error compiling the ' + path + ' template into Hogan'; + console.log(String.prototype.hasOwnProperty('red') && message.red || message); + throw new Error(e); + compiledTemplate = '

Error

'; + } + + return 't[\'' + id + '\']=new ht(' + compiledTemplate + ');'; + } + } +} +``` + + + +¿©±â¿¡¼­ `prefix`¿Í `suffix`´Â °¢°¢ ÇÑ ¹ø¾¿ È£ÃâµË´Ï´Ù. ÀÌ È£ÃâµÇ´Â °Í »çÀÌ¿¡ ÀÌ ÅÛÇø´ ¿£ÁøÀÌ Çڵ鸵ÇÏ´Â ¸ðµç ÆÄÀÏ¿¡ ´ëÇØ¼­ `process`°¡ È£ÃâµË´Ï´Ù. + + + +ÀÌ ¿¹Á¦¿¡¼­, ·¡ÆÛ´Â ÅÛÇø´À» ¼­¹ö Ãø¿¡¼­ ÄÄÆÄÀÏÇϰí ÀÖ½À´Ï´Ù. ±×¸®°í ³ª¼­ ÄÄÆÄÀÏµÈ ÅÛÇø´À» Ŭ¶óÀÌ¾ðÆ® ÂÊ¿¡ ³Ñ°ÜÁÖ°í ÀÖ½À´Ï´Ù. `prefix`¿Í `suffix` ÇÔ¼ö´Â ÄÄÆÄÀÏµÈ ÅÛÇø´À» `