pepebe
12/5/2013 - 11:26 AM

Komodo Edit: Table generator. Idea: http://www.activestate.com/blog/2013/12/auto-table-generation-snippets-ejs-komodo

<%
var cols = parseInt(ko.interpolate.interpolateString(["%(ask: How many columns?)"]));
var rows = parseInt(ko.interpolate.interpolateString(["%(ask: How many rows?)"]));
if (cols <= 0 || rows <= 0){
    alert(
        "I don't know how to make a table with \"" + cols + "\"" +
        "\n or \"" + rows + "\".  How about you try that again."
    );
} else {
    c = 0;
    r = 0;
    var filler = "<!-- Fill me in -->";
    var table = "<table>\n";
    while(c < cols) {
        r=0;
        table += "\t<tr>\n";
        while (r < rows) {         
            table += "\t\t<td>" + filler + "</td>\n";
            r++;
        }
        table += "\t</tr>\n";
        c++;
    }
    table += "</table>";
}
%>
<%= table %>