Tema: Jade y PHP
Ver Mensaje Individual
  #17 (permalink)  
Antiguo 18/12/2012, 20:02
johnse0828
 
Fecha de Ingreso: diciembre-2012
Mensajes: 24
Antigüedad: 11 años, 4 meses
Puntos: 2
Respuesta: Jade y PHP

Buenas noches @pateketrueke, ps bn, como ya lo he expresado anteriormente, no utilizo Jade Compiler para PHP porque el proyecto como tal lo estoy trabajando sobre CakePHP, por lo tanto, no puede combinar Jade Compiler for PHP con CakePHP, es por eso que pensé que utilizando el Node Template Engine de Jade podría diseñar mis interfaces de una manera muy clara, pero según veo, con Jade para Javascript no es posible :(.

En Jade Node Template Engine, hay un archivo js llamado filters.js qué es, creo yo, el archivo donde se generan los filtros, este archivo contiene lo siguiente
Código Javascript:
Ver original
  1. /*!
  2.  * Jade - filters
  3.  * Copyright(c) 2010 TJ Holowaychuk <[email protected]>
  4.  * MIT Licensed
  5.  */
  6.  
  7. module.exports = {
  8.  
  9.   /**
  10.    * Wrap text with CDATA block.
  11.    */
  12.  
  13.   cdata: function(str){
  14.     return '<![CDATA[\\n' + str + '\\n]]>';
  15.   },
  16.  
  17.   /**
  18.    * Transform sass to css, wrapped in style tags.
  19.    */
  20.  
  21.   sass: function(str){
  22.     str = str.replace(/\\n/g, '\n');
  23.     var sass = require('sass').render(str).replace(/\n/g, '\\n');
  24.     return '<style type="text/css">' + sass + '</style>';
  25.   },
  26.  
  27.   /**
  28.    * Transform stylus to css, wrapped in style tags.
  29.    */
  30.  
  31.   stylus: function(str, options){
  32.     var ret;
  33.     str = str.replace(/\\n/g, '\n');
  34.     var stylus = require('stylus');
  35.     stylus(str, options).render(function(err, css){
  36.       if (err) throw err;
  37.       ret = css.replace(/\n/g, '\\n');
  38.     });
  39.     return '<style type="text/css">' + ret + '</style>';
  40.   },
  41.  
  42.   /**
  43.    * Transform less to css, wrapped in style tags.
  44.    */
  45.  
  46.   less: function(str){
  47.     var ret;
  48.     str = str.replace(/\\n/g, '\n');
  49.     require('less').render(str, function(err, css){
  50.       if (err) throw err;
  51.       ret = '<style type="text/css">' + css.replace(/\n/g, '\\n') + '</style>';  
  52.     });
  53.     return ret;
  54.   },
  55.  
  56.   /**
  57.    * Transform markdown to html.
  58.    */
  59.  
  60.   markdown: function(str){
  61.     var md;
  62.  
  63.     // support markdown / discount
  64.     try {
  65.       md = require('markdown');
  66.     } catch (err){
  67.       try {
  68.         md = require('discount');
  69.       } catch (err) {
  70.         try {
  71.           md = require('markdown-js');
  72.         } catch (err) {
  73.           try {
  74.             md = require('marked');
  75.           } catch (err) {
  76.             throw new
  77.               Error('Cannot find markdown library, install markdown, discount, or marked.');
  78.           }
  79.         }
  80.       }
  81.     }
  82.  
  83.     str = str.replace(/\\n/g, '\n');
  84.     return md.parse(str).replace(/\n/g, '\\n').replace(/'/g,''');
  85.   },
  86.  
  87.   /**
  88.    * Transform coffeescript to javascript.
  89.    */
  90.  
  91.   coffeescript: function(str){
  92.     var js = require('coffee-script').compile(str).replace(/\\/g, '\\\\').replace(/\n/g, '\\n');
  93.     return '<script type="text/javascript">\\n' + js + '</script>';
  94.   }
  95.  
  96. };

Yo agregue estas lineas pero no sé que otras modificaciones hacerle para que pueda funcionar:

Código Javascript:
Ver original
  1. /**
  2.   * Transform php a html
  3.   */
  4.  
  5.   php: function(str){
  6.     str = str.replace(/\\n/g, '\n');
  7.     return '<?php ' + str + ' ;?>';
  8.   }

Si alguno puede ayudarme, le estaré eternamente agradecido, gracias muchachos!