CL-WHO-like HTML templating for other languages?

前端 未结 9 1061
别那么骄傲
别那么骄傲 2020-12-10 04:44

Common Lisp guys have their CL-WHO, which makes HTML templating integrated with the \"main\" language thus making the task easier. For those who don\'t know CL-WHO, it looks

9条回答
  •  伪装坚强ぢ
    2020-12-10 05:16

    Perl's CGI module has support for something like this.

    use CGI ':standard';
    use Lisp::Fmt 
    
    print header();
    
    print table( { -border => 1, -cellpading => 4},
        loop({ below => 25, by=> 5}, sub {
            my $i = shift;
            tr( {-align => 'right'} ,
                loop({ from => $i, below $i + 5}, sub {
                    my $j = shift;
                    td({-bgcolor => ($oddp eq $j ? 'pink' : 'green')}
                        fmt("~@R", 1+$j);
                })
            )
        });
    

    I tried to keep it lispy, so you'll have to implement a lispy loop function yourself. I don't really program Common List, so I hope I understood your code correctly.

提交回复
热议问题