{"id":96,"date":"2018-04-04T13:25:08","date_gmt":"2018-04-04T04:25:08","guid":{"rendered":"http:\/\/rugoh.co.jp\/blog\/?p=96"},"modified":"2018-04-08T23:23:39","modified_gmt":"2018-04-08T14:23:39","slug":"fuelphp%e3%81%a7smarty%e3%81%ab%e5%8b%95%e7%9a%84%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%82%92%e4%bb%95%e8%be%bc%e3%82%80","status":"publish","type":"post","link":"https:\/\/rugoh.co.jp\/blog\/2018\/04\/04\/fuelphp%e3%81%a7smarty%e3%81%ab%e5%8b%95%e7%9a%84%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%82%92%e4%bb%95%e8%be%bc%e3%82%80\/","title":{"rendered":"FuelPHP\u3067Smarty\u306b\u52d5\u7684\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4ed5\u8fbc\u3080"},"content":{"rendered":"<p>FuelPHP\u3067Smarty\u3092\u4f7f\u3044<br \/>\nSmarty\u306eregisterPlugin\u95a2\u6570\u3092\u4f7f\u3046\u969b\u306e\u30e1\u30e2<\/p>\n<p>FuelPHP\u3067Smarty\u3092\u4f7f\u3046\u5834\u5408<br \/>\n<a href=\"https:\/\/qiita.com\/tageo\/items\/aa1193e45512a899c068\" target=\"_blank\" rel=\"noopener\">FuelPHP1.7.3\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u306bsmarty\u3092\u8a2d\u5b9a<\/a><br \/>\n\u3053\u3061\u3089\u306e\u30b5\u30a4\u30c8\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3084\u308a\u305f\u3044\u4e8b\u306f\u3001<br \/>\n\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u3067<\/p>\n<pre>{less file=\"style\"}<\/pre>\n<p>\u3053\u3093\u306a\u95a2\u6570\u3092\u4f7f\u3044\u305f\u3044\u3002<\/p>\n<p>\u3069\u3093\u306a\u51e6\u7406\u3092\u3057\u305f\u3044\u304b\u3068\u3044\u3046\u3068<br \/>\nLESS\u3092\u81ea\u52d5\u7684\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3001\u30b3\u30f3\u30d1\u30a4\u30eb\u3055\u308c\u305fcss\u306e\u30d1\u30b9\u3092\u8868\u793a\u3057\u305f\u3044<\/p>\n<p>\/app\/classes\/controller\/index.php<\/p>\n<pre>class Controller_Index extends \\Controller\r\n{\r\n  public function action_index(){\r\n    $view = \\View_Smarty::forge('index');\r\n    return $view;\r\n  }\r\n}\r\n<\/pre>\n<p>\/app\/views\/index.tpl<\/p>\n<pre>{less file=\"style\"}\r\n<\/pre>\n<p>\u307e\u305a\u3001\u3053\u306e\u72b6\u614b\u3067\u306f\u3001\u30a8\u30e9\u30fc\u306b\u306a\u308b\u3002<br \/>\nless\u306a\u3093\u3066\u95a2\u6570\u306fSmarty\u306b\u306f\u306a\u3044\u304b\u3089\u5f53\u305f\u308a\u524d\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001Controller\u5074\u3067Smarty\u306b\u95a2\u6570\u3092\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n<p>\/app\/classes\/controller\/index.php<\/p>\n<pre>class Controller_Index extends \\Controller\r\n{\r\n  public function action_index()\r\n  {\r\n    <span style=\"color: red;\">\\View_Smarty::parser()-&gt;registerPlugin('function', 'less', array($this,'smarty_function_less'));<\/span>\u3000\/\/\u2190\u8ffd\u8a18\r\n    $view = \\View_Smarty::forge('index');\r\n    return $view;\r\n  }\r\n\r\n<span style=\"color: red;\">\/\/ \u2193\u8ffd\u8a18\r\n  public function smarty_function_less($params, $smarty)\r\n  {\r\n    $file = $params['file'];\r\n    if( !preg_match('\/\\.less$\/',$file ) )\r\n    {\r\n      $file .= '.less';\r\n    }\r\n    return \\Asset::less($file);\r\n  }\r\n<\/span>\r\n}\r\n<\/pre>\n<p><code>\\View_Smarty::parser()-&gt;registerPlugin('function', 'less', array($this,'smarty_function_less'));<\/code><\/p>\n<p>\\View_Smarty\u304b\u3089parser()\u95a2\u6570\u3067Smarty\u306e\u30af\u30e9\u30b9\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<br \/>\nstatic\u306a\u30af\u30e9\u30b9\u304c\u7372\u5f97\u3067\u304d\u308b\u306e\u3067\u3001\u3053\u308c\u306b\u5bfe\u3057\u3066registerPlugin()\u3059\u308c\u3070<br \/>\n\u6052\u4e45\u7684\u306b\u95a2\u6570\u3092\u767b\u9332\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>less\u3068\u3044\u3046function\u3092\u767b\u9332\u3057\u3001<br \/>\n\u5b9f\u969b\u306b\u51e6\u7406\u3055\u308c\u308b\u306e\u306f\u3001$this\u306esmarty_function_less\u3068\u3044\u3046\u95a2\u6570<\/p>\n<p><code>$file = $params['file'];<br \/>\nif( !preg_match('\/\\.less$\/',$file ) )<br \/>\n{<br \/>\n$file .= '.less';<br \/>\n}<\/code><\/p>\n<p>\u62e1\u5f35\u5b50\u304c\u7121\u304b\u3063\u305f\u3089\u88dc\u5b8c\u3057\u3066\u3042\u3052\u308b\u3002<\/p>\n<p><code>return \\Asset::less($file);<\/code><\/p>\n<p>LESS\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3066\u30d1\u30b9\u3092\u8fd4\u3059<\/p>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001<\/p>\n<pre>{less file=\"style\"}<\/pre>\n<p>\u304c\u3001<\/p>\n<pre>&lt;link type=\"text\/css\" rel=\"stylesheet\" href=\"\/assets\/ccss\/style.css?1523197338\" \/&gt;<\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u5909\u63db\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>LESS\u3092\u4f7f\u3046\u305f\u3081\u306e\u89e3\u8aac\u306f<br \/>\n<a href=\"\/blog\/2018\/04\/02\/fuelphp_less\/\">CentOS7\u3067FuelPHP\u3067less\u3092\u4f7f\u3046<\/a><br \/>\n\u3092\u53c2\u8003\u306b\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FuelPHP\u3067Smarty\u3092\u4f7f\u3044 Smarty\u306eregisterPlugin\u95a2\u6570\u3092\u4f7f\u3046\u969b\u306e\u30e1\u30e2 FuelPHP\u3067Sma&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":102,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[],"_links":{"self":[{"href":"https:\/\/rugoh.co.jp\/blog\/wp-json\/wp\/v2\/posts\/96"}],"collection":[{"href":"https:\/\/rugoh.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rugoh.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rugoh.co.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rugoh.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=96"}],"version-history":[{"count":8,"href":"https:\/\/rugoh.co.jp\/blog\/wp-json\/wp\/v2\/posts\/96\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/rugoh.co.jp\/blog\/wp-json\/wp\/v2\/posts\/96\/revisions\/121"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rugoh.co.jp\/blog\/wp-json\/wp\/v2\/media\/102"}],"wp:attachment":[{"href":"https:\/\/rugoh.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rugoh.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rugoh.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}