<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>BufferOverflow &#187; Desarrollo Web</title> <atom:link href="http://www.bufferoverflow.com.ar/category/desarrollo-web/feed/" rel="self" type="application/rss+xml" /><link>http://www.bufferoverflow.com.ar</link> <description>Desbordando no sólo buffers</description> <lastBuildDate>Tue, 17 Jan 2012 00:41:56 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Montar automáticamente unidades SSH con SSHFS</title><link>http://www.bufferoverflow.com.ar/montar-automaticamente-unidades-ssh-con-sshfs/</link> <comments>http://www.bufferoverflow.com.ar/montar-automaticamente-unidades-ssh-con-sshfs/#comments</comments> <pubDate>Thu, 01 Dec 2011 01:10:16 +0000</pubDate> <dc:creator>neiker</dc:creator> <category><![CDATA[Desarrollo Web]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[ssh]]></category> <category><![CDATA[sshfs]]></category> <guid
isPermaLink="false">http://www.bufferoverflow.com.ar/?p=406</guid> <description><![CDATA[Muchas veces trabajamos en servidores remotos y, por diferentes motivos, necesitamos tener una unidad montada localmente. Con sshfs podemos montar cualquier directorio remoto en un directorio local de la siguiente manera: $ sshfs &#91;nombre de usuario&#93;@&#91;host&#93;:/&#91;directorio remoto&#93; /&#91;directorio local&#93; Pero de esta forma, tendríamos que ingresar este comando cada vez que quisiéramos montar esta unidad. [...]]]></description> <content:encoded><![CDATA[<p><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2011/11/sshfs.png"><img
src="http://www.bufferoverflow.com.ar/wp-content/uploads/2011/11/sshfs.png" alt="" title="sshfs" width="128" height="128" class="alignleft size-full wp-image-417" /></a>Muchas veces trabajamos en servidores remotos y, por diferentes motivos, necesitamos tener una unidad montada localmente. Con sshfs podemos montar cualquier directorio remoto en un directorio local de la siguiente manera:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">$ sshfs <span style="color: #7a0874; font-weight: bold;">&#91;</span>nombre de usuario<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>:<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>directorio remoto<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>directorio <span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div><p>Pero de esta forma, tendríamos que ingresar este comando cada vez que quisiéramos montar esta unidad. Para hacerlo de manera automatica, al inicio del sistema en GNU/Debian, agregamos esta linea a nuestro .bashrc (se ubica en nuestro home, en caso de que no exista deberemos crearlo):</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[contraseña]&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> sshfs <span style="color: #7a0874; font-weight: bold;">&#91;</span>user<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>:<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>directorio remoto<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>directorio <span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #660033;">-o</span> <span style="color: #007800;">workaround</span>=rename <span style="color: #660033;">-o</span> password_stdin</pre></div></div><p>Por ejemplo, en el archivo /home/javier/.bashrc:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;asd123&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> sshfs javier<span style="color: #000000; font-weight: bold;">@</span>ejemplo.com:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>javier<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>javier<span style="color: #000000; font-weight: bold;">/</span>remoto <span style="color: #660033;">-o</span> <span style="color: #007800;">workaround</span>=rename <span style="color: #660033;">-o</span> password_stdin</pre></div></div><p><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.bufferoverflow.com.ar%2Fmontar-automaticamente-unidades-ssh-con-sshfs%2F&amp;title=Montar%20autom%C3%A1ticamente%20unidades%20SSH%20con%20SSHFS" id="wpa2a_2"><img
src="http://www.bufferoverflow.com.ar/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://www.bufferoverflow.com.ar/montar-automaticamente-unidades-ssh-con-sshfs/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>AutoSuggest: Plugin jQuery para auto-completado</title><link>http://www.bufferoverflow.com.ar/autosuggest-plugin-auto-completado-jquery/</link> <comments>http://www.bufferoverflow.com.ar/autosuggest-plugin-auto-completado-jquery/#comments</comments> <pubDate>Tue, 30 Mar 2010 04:28:50 +0000</pubDate> <dc:creator>neiker</dc:creator> <category><![CDATA[Desarrollo Web]]></category> <category><![CDATA[ajax]]></category> <category><![CDATA[css]]></category> <category><![CDATA[html]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[jquery]]></category> <guid
isPermaLink="false">http://www.bufferoverflow.com.ar/?p=334</guid> <description><![CDATA[AutoSuggest es un plugin para jQuery que nos permite crear fácilmente una caja de texto con auto-completado.]]></description> <content:encoded><![CDATA[<p><strong><a
href="http://code.drewwilson.com/entry/autosuggest-jquery-plugin">AutoSuggest</a></strong> es un plugin para <strong><a
href="http://jquery.com/">jQuery</a></strong> que nos permite convertir fácilmente cualquier <strong>INPUT</strong> de texto en una caja con auto-completado. La misma se crea con una estructura HTML totalmente limpia y sin utilizar imágenes, lo que permite la fácil personalización visual con <strong>CSS</strong>. El plugin tiene un peso de apenas <strong>9,6KiB</strong>.</p><p><a
href="http://code.drewwilson.com/entry/autosuggest-jquery-plugin"><img
class="aligncenter size-full wp-image-340" title="AutoSuggest" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/03/AutoSuggest.jpg" alt="" width="640" height="226" /></a></p><p><object
classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="651" height="366" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param
name="allowfullscreen" value="true" /><param
name="allowscriptaccess" value="always" /><param
name="src" value="http://vimeo.com/moogaloop.swf?clip_id=9312964&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" /><embed
type="application/x-shockwave-flash" width="651" height="366" src="http://vimeo.com/moogaloop.swf?clip_id=9312964&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p><p>Para utilizarlo, incluimos <strong>jQuery</strong> (en mi caso siempre lo cargo desde Google) y el plugin.</p><div
class="wp_syntax"><div
class="code"><pre class="html" style="font-family:monospace;">&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;../scripts/jquery.autoSuggest.minified.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></div></div><p>Se puede utilizar de la siguiente manera:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#auto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">autoSuggest</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div><p>Donde <strong>#auto</strong> es el INPUT que queremos utilizar y <strong>data</strong> son las sugerencias, estas pueden ser obtenidas desde un array incluido en el mismo script (sin hacer una llamada ajax) o desde una URL (utilizando ajax). Veamos como un ejemplo utilizando un array dentro del mismo script:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
 data <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>items<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Mick Jagger&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Johnny Storm&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Richard Hatch&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Kelly Slater&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Rudy Hamilton&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Michael Jordan&quot;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#auto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">autoSuggest</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">items</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div><p>O haciendo una peticion ajax:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#auto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">autoSuggest</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;auto.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div><p>Donde el script PHP puede ser algo como esto:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?PHP</span>
    <span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;q&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// query your DataBase here looking for a match to $input</span>
    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM my_table WHERE my_field LIKE '%<span style="color: #006699; font-weight: bold;">$input</span>%'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$json</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$json</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$json</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$json</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user_photo'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$json</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><p>Cuando se van seleccionando las opciones, estas se guardan en un campo oculto separadas por coma. El name del campo oculto es <strong>as_values_</strong> seguido del string que especifiquemos nosotros con la opcion <strong>asHtmlID</strong>. Por ej, si queremos que el name sea <strong>as_values_nombres</strong>:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#auto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">autoSuggest</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;auto.php&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>asHtmlID<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;nombres&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div><p>Luego con PHP usamos:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'as_values_nombres'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div><h3>Tenemos algunas opciones mas:</h3><p><strong>selectionLimit: </strong> numero (Valor por defecto: Sin limite) Especifica la cantidad máxima de items que se pueden seleccionar, por ej si queremos que solo se puedan seleccionar 3 items:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#auto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">autoSuggest</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;auto.php&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>asHtmlID<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;nombres&quot;</span><span style="color: #339933;">,</span> selectionLimit<span style="color: #339933;">:</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div><p><strong>limitText: </strong> string (Valor por defecto: &#8220;No More Selections Are Allowed&#8221;) Texto que se muestra cuando se alcanza el limite especificado con selectionLimit.<br
/> <strong>emptyText: </strong>string (Valor por defecto: &#8220;No Results&#8221;) Texto que se muestra al no encontrar coincidencias<br
/> <strong>selectedItemProp:</strong>string (Valor por defecto: &#8220;value&#8221;) El nombre de la propiedad del objeto que se va a usar para mostrar.<br
/> <strong>selectedValuesProp:</strong>string (Valor por defecto: &#8220;value&#8221;) El nombre de la propiedad del objeto que se va a guardar en el campo oculto.<br
/> <strong>searchObjProps:</strong>string (Valor por defecto: &#8220;value&#8221;) El nombre de la propiedad del objeto que se va a usar para la busqueda. Si se quieren usar varias opciones se las puede separar con coma.<br
/> El uso de las tres opciones anteriores puede ser algo confuso, pero puede ser mas facil entenderlo con el siguiente ejemplo:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>items<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;21&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Mick Jagger&quot;</span><span style="color: #339933;">,</span> searchname<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Mick Jagger, Mick Jager&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;43&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Johnny Storm&quot;</span><span style="color: #339933;">,</span> searchname<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Johnny Storm&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;46&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Richard Hatch&quot;</span><span style="color: #339933;">,</span> searchname<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Richard Hatch&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;54&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Kelly Slater&quot;</span><span style="color: #339933;">,</span> searchname<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Kelly Slater&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;55&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Rudy Hamilton&quot;</span><span style="color: #339933;">,</span> searchname<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Rudy Hamilton&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;79&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Michael Jordan&quot;</span><span style="color: #339933;">,</span> searchname<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Michael Jordan&quot;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#auto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">autoSuggest</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;auto.php&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>selectedValuesProp<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;value&quot;</span><span style="color: #339933;">,</span> selectedItemProp<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">,</span> searchObjProps<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;searchname&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div><p>De esa forma <strong>value</strong> se guardara en el campo oculto y sera enviado con el formulario (Si se selecciona a Mick Jagger y a Kelly Slater, entonces lo que se enviará con el formulario será: &#8220;21, 54&#8243;), <strong>name</strong> se mostrará al usuario y <strong>searchname</strong> se usará para buscar coincidencias con el texto ingresado.</p><p><strong>startText:</strong> string (Valor por defecto: &#8220;Enter Name Here&#8221;) Texto a mostrar cuando el campo de texto esta vacío.<br
/> <strong>preFill: </strong>objeto o string (Valor por defecto: Objeto vacío) Opciones ya seleccionadas cuando se carga la pagina. Se le puede pasar un string con las opciones separadas por coma o un objeto.<br
/> <strong>queryParam: </strong>string (Valor por defecto: &#8220;q&#8221;) Nombre del parámetro que se va a usar para la petición ajax. auto.php?q=<br
/> <strong>retrieveLimit: </strong>numero (Vacío por defecto) Puede ser usado para especificar un limite en el query ajax ya que agrega un &amp;limit= en el mismo.<br
/> <strong>extraParams: </strong>string (Vacío por defecto) Sirve para especificar cualquier otro parámetro en la petición ajax. En el caso de que sean varios, recordá seprarlos con un andpersand (&amp;).<br
/> <strong>matchCase: </strong>true o false (Valor por defecto: false)  hace que la busqueda sea case sensitive en caso de ser true.<br
/> <strong>minChars: </strong>numero (Valor por defecto: 1)  Cantidad de caracteres que son necesarios para que comience la busqueda.<br
/> <strong>keyDelay: </strong>numero (Valor por defecto: 400) Tiempo de espera en milisegundos antes de que comience la búsqueda. El valor por defecto es 400.<br
/> <strong>showResultList: </strong>true o false (Valor por defecto: true) Si se establece en false, la lista desplegable con las opciones nunca se mostrará.<br
/> <strong>start: </strong> Permite establecer una función personalizada que se activa al ejecutar AutoSuggest (en la mayoria de los casos, al cargar la pagina).<br
/> <strong>selectionClick:</strong> Permite establecer una funcion personalizada que se activa cuando se hace click sobre una opcion ya haya sido seleccionada previamente.<br
/> <strong>selectionAdded: </strong>Permite establecer una funcion personlizada que se activa cuando se selecciona una opción de la lista.<br
/> <strong>selectionRemoved:</strong> Permite establecer una función personalizada que se activa cuando se elimina una opción ya seleccionada. Tal vez un efecto fadeout en el elemento eliminado.<br
/> <strong>beforeRetrieve:</strong> Funcion que se aplica antes de comenzar a buscar. Se puede usar por ej, para mostrar un gif &#8220;loading&#8221; mientras se hace la peticion ajax.<br
/> <strong>retrieveComplete: </strong>Funcion que se ejecuta cuando se termina de buscar. Se puede usar para ocultar el gif antes mencionado.<br
/> <strong>resultClick: </strong>Funcion que se ejecuta al hacer click sobre alguna de las opciones de la lista desplegable.<br
/> <strong>resultsComplete: </strong> Permite especificar una funcion personalizada a ejecutarse una vez desplegada la lista de resultados.</p> ]]></content:encoded> <wfw:commentRss>http://www.bufferoverflow.com.ar/autosuggest-plugin-auto-completado-jquery/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>HTML5: Novedades en los formularios</title><link>http://www.bufferoverflow.com.ar/html5-novedades-en-los-formularios/</link> <comments>http://www.bufferoverflow.com.ar/html5-novedades-en-los-formularios/#comments</comments> <pubDate>Sat, 09 Jan 2010 20:10:07 +0000</pubDate> <dc:creator>neiker</dc:creator> <category><![CDATA[Desarrollo Web]]></category> <category><![CDATA[email html5]]></category> <category><![CDATA[Formularios]]></category> <category><![CDATA[formularios html5]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[html5 javascript]]></category> <category><![CDATA[input html5]]></category> <category><![CDATA[Internet Explorer]]></category> <category><![CDATA[iphone]]></category> <category><![CDATA[Mozilla Firefox]]></category> <category><![CDATA[Opera]]></category> <category><![CDATA[Safari]]></category> <category><![CDATA[validacion html5]]></category> <guid
isPermaLink="false">http://www.bufferoverflow.com.ar/?p=219</guid> <description><![CDATA[HTML5 nos trae muchas características interesantes, repasamos cuales son las principales novedades en los formularios.]]></description> <content:encoded><![CDATA[<p><a
href="http://diveintohtml5.info/forms.html"><img
class="alignleft size-full wp-image-249" title="html5" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/html5.gif" alt="" width="250" height="198" />HTML5 nos trae varias novedades</a> para nuestros formularios que podemos implementar actualmente, porque a pesar de que <strong>HTML5</strong> no estará completamente listo hasta el 2012, muchos navegadores empiezan a implementar algunas de sus características.<br
/> En el caso de que utilicemos estas características y el navegador no sea compatible con las misma, simplemente las ignorará sin causarnos mayores problemas.  Incluso podremos condicionar nuestros scripts para que funcionen solo en navegadores sin soporte para las nuevas características de manejo de formularios, por ej si tenemos un script de selección de fechas podremos hacer que funcione solo en Internet Explorer pero que en Opera sea el mismo navegador el que se encargué de mostrarnos su selector de fechas.</p><h2>Placeholder:</h2><p>Si no disponemos de las características de los nuevos formularios HTML5, la forma común de hacer un placeholder sería con JavaScript jugando con los eventos de focos. Hoy en día, podemos con este atributo podremos agregar un texto que se verá en el input cuando este esté vacío y no tenga el foco.</p><p><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/location-bar-empty-unfocused.png"><img
class="size-full wp-image-220 alignleft" title="location-bar-empty-unfocused" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/location-bar-empty-unfocused.png" alt="" width="268" height="30" /></a></p><pre><code>&lt;input type="text" placeholder="Search Bookmarks and History"&gt;
</code></pre><p>Actualmente solo es compatible con Chromium/Chrome y Safari 4, para verlo en funcionamiento entrá <a
href="http://diveintohtml5.info/examples/input-placeholder.html">acá</a>.</p><h2>Autofocus:</h2><p>Otra muy buena ventaja de los formularios en HTML5, este es otro claro ejemplo que permite el control del autofoco sin hacer uso de JavaScript, como se hubiera hecho antes. Como su nombre lo indica, con autofocus establecemos que un input tendrá el foco. No tiene mucha ciencia, simplemente agregamos &#8220;autofocus&#8221; en el elemento:</p><pre><code>&lt;input id="q" type="text" autofocus&gt;</code></pre><p>Si tenés un <span
style="text-decoration: line-through;">molesto</span> script de autofoco en tu web, no te preocupes ya que seguirá funcionando sin importar que el navegador sea compatible o no con el atributo autofocus, pero si queres que el script se ejecute solo si no lo es podes agregar un if de esta forma:</p><pre><code>&lt;script&gt;
  window.onload = function() {
    if (!("autofocus" in document.createElement("input"))) {
      document.getElementById("q").focus();
    }
  }
&lt;/script&gt;</code></pre><h2>Nuevos tipos de INPUT</h2><p>HTML5 nos trae varios nuevos tipos de INPUT, en los navegadores que no los soporten, serán tomados simplemente como type=&#8221;text&#8221;.</p><p>Uno de los nuevos tipos de input es el tipo &#8220;email&#8221; que nos servirá, justamente, para campos en los que se requiera ingresar una dirección de mail.  Si tenés Opera y ves <a
href="http://diveintohtml5.info/examples/input-type-email.html">este demo</a> vas a ver un pequeño icono junto a los campos de este tipo y en iPhone,  el teclado virtual se transformará de esta forma:</p><p><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-email.png"><img
class="aligncenter size-full wp-image-222" title="input-type-email" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-email.png" alt="" width="267" height="400" /></a></p><p>Tambien tenemos el tipo URL que nos sirve para direcciones web</p><pre><code> &lt;input type="url"&gt;</code></pre><p>Para numeros tenemos 2 nuevos tipos, el primero es &#8220;number&#8221;:</p><p><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-number-opera.png"><img
class="aligncenter size-full wp-image-232" title="input-type-number-opera" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-number-opera.png" alt="" width="227" height="203" /></a>Que como vemos nos deja asignar restricciones de la misma manera que lo hace el tipo &#8220;range&#8221;:</p><p
style="text-align: center;"><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-range.png"><img
class="aligncenter size-full wp-image-233" title="input-type-range" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-range.png" alt="" width="175" height="25" /></a> &lt;input type=&#8221;range&#8221;        min=&#8221;0&#8243;        max=&#8221;10&#8243;        step=&#8221;2&#8243; <code> value="6"&gt;</code></p><p
style="text-align: center;"><p>Otro punto al que se le prestó mucha atención es al tema fechas, para su manejo contamos con diferentes tipos de campo. Acá dejo algunas capturas de como se ven los diferentes campos para fechas en Opera (Único navegador que actualmente los soporta):</p><p><strong>type=&#8221;date&#8221;</strong></p><p><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-date.png"><img
class="alignnone size-full wp-image-234" title="input-type-date" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-date.png" alt="" width="210" height="190" /></a></p><p><strong>type=&#8221;mounth</strong>&#8221;</p><p><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-month.png"><img
class="alignnone size-full wp-image-236" title="input-type-month" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-month.png" alt="" width="210" height="189" /></a></p><p><strong>type=&#8221;week</strong>&#8221;</p><p><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-week.png"><img
class="alignnone size-full wp-image-237" title="input-type-week" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-week.png" alt="" width="210" height="191" /></a></p><p><strong>type&#8221;time</strong>&#8221;</p><p><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-time.png"><img
class="alignnone size-full wp-image-238" title="input-type-time" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-time.png" alt="" width="98" height="22" /></a></p><p><strong>type=&#8221;datetime</strong>&#8221;</p><p><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-datetime.png"><img
class="alignnone size-full wp-image-235" title="input-type-datetime" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-datetime.png" alt="" width="225" height="191" /></a></p><p>Si queres implementar tu script de selección de fechas solo en los exploradores que no son compatibles con estos tipos de campos, podes <a
href="http://diveintohtml5.info/detect.html#input-types">implementar una comprobación</a> de esta forma:</p><pre><code>&lt;script&gt;
  var i = document.createElement("input");
  i.setAttribute("type", "date");
  if (i.type == "text") {
    // No soportado
  }
&lt;/script&gt;</code></pre><p>Pero esto no termina aća, además tenemos un nuevo tipo de campo especialmente pensado para cajas de búsqueda llamado &#8220;search&#8221;.</p><p><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-search-safari-typing.png"><img
class="size-full wp-image-240 alignleft" title="input-type-search-safari-typing" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/input-type-search-safari-typing.png" alt="" width="191" height="121" /></a></p><p>Si usas este tipo de campo en cualquier explorador actual no vas a notar ninguna diferencia, a no ser que uses Safari sobre MacOS X en donde vas a ver el campo type=&#8221;search&#8221; con las esquinas redondeadas y al empezar a escribir aparecerá una pequeña cruz a la derecha que nos permite borrar el contenido del campo.</p><p><a
href="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/javascript-color-picker-300x193.png"><img
class="size-full wp-image-243 alignright" title="javascript-color-picker-300x193" src="http://www.bufferoverflow.com.ar/wp-content/uploads/2010/01/javascript-color-picker-300x193.png" alt="" width="300" height="193" /></a></p><p>Por ultimo tenemos el tipo &#8220;color&#8221;, que actualmente no es soportado por ningún explorador, pero que en teoría serviría para colores en hexadecimal. Y seguramente será complementado con un selector de color.</p><h2>Conclusión:</h2><p>Estas nuevas implementaciones nos simplificaran mucho el trabajo ya que contaremos con soporte nativo para los tipos de datos que mas se manejan en los formularios (bueno, tal vez algunos sean mas <span
style="text-decoration: line-through;">in</span>útiles que otros), lo que no hará mas fácil por ej la validación desde el lado del cliente, por cierto, me olvidaba del nuevo atributo  <a
href="http://www.whatwg.org/specs/web-forms/current-work/#the-required">required</a>.</p><pre id="example-validation"><code>&lt;form&gt;
 &lt;p&gt;&lt;label&gt;Nombre: &lt;input name="name" <strong>required</strong>&gt;&lt;/label&gt;&lt;/p&gt;
 &lt;p&gt;&lt;label&gt;E-mail: &lt;input name="email" <strong>type="email" required</strong>&gt;&lt;/label&gt;&lt;/p&gt;
 &lt;p&gt;&lt;label&gt;URL: &lt;input name="url" <strong>type="url"</strong>&gt;&lt;/label&gt;&lt;/p&gt;
 &lt;p&gt;&lt;label&gt;Comentario: &lt;textarea name="comment" <strong>required</strong>&gt;&lt;/textarea&gt;&lt;/label&gt;&lt;/p&gt;
 &lt;p&gt;&lt;input type="submit" value="Enviar"&gt;&lt;/p&gt;
&lt;/form&gt;</code></pre><p>Tendremos que esperar unos años hasta que estas características sean totalmente compatibles con los diferentes navegadores, Opera es uno de los que mayor compatibilidad tiene, seguido por Chrome y Safari, pero Internet Explorer y Firefox todavia no soportan ninguna de estas características. Seguramente en los próximos meses empezaremos a ver novedades al respecto en Firefox, pero Microsoft creo que <span
style="text-decoration: line-through;">como siempre</span> va a tardar algun tiempo mas.</p><p>Pueden leer el articulo original (en ingles) en <a
href="http://diveintohtml5.info/forms.html">diveintohtml5.info</a>.</p> ]]></content:encoded> <wfw:commentRss>http://www.bufferoverflow.com.ar/html5-novedades-en-los-formularios/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Jaml, linda forma de generar HTML con Javascript</title><link>http://www.bufferoverflow.com.ar/jaml-linda-forma-de-generar-html-con-javascript/</link> <comments>http://www.bufferoverflow.com.ar/jaml-linda-forma-de-generar-html-con-javascript/#comments</comments> <pubDate>Sat, 12 Dec 2009 13:42:36 +0000</pubDate> <dc:creator>neiker</dc:creator> <category><![CDATA[Desarrollo Web]]></category> <category><![CDATA[generar]]></category> <category><![CDATA[html]]></category> <category><![CDATA[jaml]]></category> <category><![CDATA[javascript]]></category> <guid
isPermaLink="false">http://www.bufferoverflow.com.ar/?p=147</guid> <description><![CDATA[Jaml es una librería JavaScript para generar elementos DOM de manera sencilla.]]></description> <content:encoded><![CDATA[<p><a
href="http://edspencer.net/2009/11/jaml-beautiful-html-generation-for-javascript.html">Jaml</a> es una libreria con la que podremos generar elementos DOM de una manera sencilla, con una sintaxis tan simple como esta:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;">div<span style="color: #009900;">&#40;</span>
 h1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>cls<span style="color: #339933;">:</span> <span style="color: #3366CC;">'titulo'</span><span style="color: #009900;">&#125;</span><span style="color: #3366CC;">&quot;Some title&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 p<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Some exciting paragraph text&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 br<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 ul<span style="color: #009900;">&#40;</span>
   li<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;First item&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   li<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Second item&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   li<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Third item&quot;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>Se generará lo siguiente:</p><div
class="wp_syntax"><div
class="code"><pre class="html" style="font-family:monospace;">&lt;div&gt;
&nbsp;
&lt;h1 class=&quot;titulo&quot;&gt;Some title&lt;/h1&gt;
&nbsp;
&nbsp;
Some exciting paragraph text
&nbsp;
&lt;ul&gt;
&nbsp;
	&lt;li&gt;First item&lt;/li&gt;
&nbsp;
&nbsp;
	&lt;li&gt;Second item&lt;/li&gt;
&nbsp;
&nbsp;
	&lt;li&gt;Third item&lt;/li&gt;
&nbsp;
&lt;/ul&gt;
&lt;/div&gt;</pre></div></div><p>Ademas, cuenta con metodos que permiten la creacion de templates, veamos un ejemplo:<br
/> Registramos la plantilla:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;">Jaml.<span style="color: #660066;">register</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'product'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>product<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 div<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>cls<span style="color: #339933;">:</span> <span style="color: #3366CC;">'product'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   h1<span style="color: #009900;">&#40;</span>product.<span style="color: #660066;">title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   p<span style="color: #009900;">&#40;</span>product.<span style="color: #660066;">description</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   img<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>src<span style="color: #339933;">:</span> product.<span style="color: #660066;">thumbUrl</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   a<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>href<span style="color: #339933;">:</span> product.<span style="color: #660066;">imageUrl</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'View larger image'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   form<span style="color: #009900;">&#40;</span>
    label<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'for'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'quantity'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Quantity&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    input<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'text'</span><span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'quantity'</span><span style="color: #339933;">,</span> id<span style="color: #339933;">:</span> <span style="color: #3366CC;">'quantity'</span><span style="color: #339933;">,</span> value<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    input<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'submit'</span><span style="color: #339933;">,</span> value<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Add to Cart'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>Luego cargamos un objeto:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> bsg <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
 title      <span style="color: #339933;">:</span> <span style="color: #3366CC;">'Battlestar Galactica DVDs'</span><span style="color: #339933;">,</span>
 thumbUrl   <span style="color: #339933;">:</span> <span style="color: #3366CC;">'thumbnail.png'</span><span style="color: #339933;">,</span>
 imageUrl   <span style="color: #339933;">:</span> <span style="color: #3366CC;">'image.png'</span><span style="color: #339933;">,</span>
 description<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Best. Show. Evar.'</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div><p>Y finalmente le pasamos el objeto y el template a Jaml.render()</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;">Jaml.<span style="color: #660066;">render</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'product'</span><span style="color: #339933;">,</span> bsg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>De esa forma obtendremos esta salida:</p><div
class="wp_syntax"><div
class="code"><pre class="html" style="font-family:monospace;">&lt;div&gt;
&nbsp;
&lt;h1&gt;Battlestar Galactica DVDs&lt;/h1&gt;
&nbsp;
&nbsp;
Best. Show. Evar.
&nbsp;
 &lt;img src=&quot;thumbnail.png&quot; alt=&quot;&quot; /&gt;
 &lt;a href=&quot;image.png&quot;&gt;View larger image&lt;/a&gt;
&lt;form&gt;
   &lt;label for=&quot;quantity&quot;&gt;Quantity&lt;/label&gt;
&lt;input id=&quot;quantity&quot; name=&quot;quantity&quot; type=&quot;text&quot; value=&quot;1&quot; /&gt;
&lt;input type=&quot;submit&quot; value=&quot;Add to Cart&quot; /&gt;
&lt;/form&gt;&lt;/div&gt;</pre></div></div><p>Pueden descargarla y ver mas ejemplos en la <a
href="http://edspencer.github.com/jaml/">web oficial</a>.</p> ]]></content:encoded> <wfw:commentRss>http://www.bufferoverflow.com.ar/jaml-linda-forma-de-generar-html-con-javascript/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
