Sean Lou


  • Web开发中初学者容易混淆的9个命名约定

    Posted in • javascript at 2012-03-15 by lxj


    1. 类属性名前加下划线



    1 class MyClass {
    2    // 这个实例变量在类外部无法访问
    3    private $_someVariable;
    5    // 这个方法仅在类内部或者其它继承它的类中可用
    6    protected function __behindTheScenesMethod() {}
    7 }

    Read on →

  • Node.js使用 Mustache.js做模板

    Posted in • javascript at 2012-03-12 by lxj


    为了让 Node.js 输出更多的 HTML 元素,我们可以借助一些 html 模板引擎,例如 Mustache。

    首先在 Node.js 中安装 Mustache:

    npm install mustache



        var mustache = require('./node_modules/mustache/mustache');
        function helloworld(response)
          console.log('request recieved at ' + (new Date()).getTime());
          response.writeHead(200, {'Content-Type': 'text/html'});
          var template = '<h1>Test</h1><p></p>';
          var model = {helloworld:'Hello World'};
        exports.helloworld = helloworld;

    Read on →

  • Jekyll Pagination

    Posted in • plugins at 2012-03-09 by lxj


    Note: Pagination does not work with markdown files, it only works with html file extensions.

    Just follow these steps to add pagination to your blog:


    add the pagination setting: yaml markdown: rdiscount pygments: true lsi: true exclude: ['README.markdown', 'README_FOR_COLLABORATORS.markdown', 'Gemfile.lock', 'Gemfile'] production: false //add this line to add pagination paginate: 3 //the number of post per page

    Read on →

  • Jekyll Usage

    Posted in • other at 2012-03-08 by lxj


    Creating a Jekyll site usually involves the following, [[once jekyll is installed.|Install]]

    1. Set up the basic structure of the site
    2. Create some posts, or [[import them from your previous platform|Blog migrations]]
    3. Run your site locally to see how it looks
    4. Deploy your site

    Basic Structure

    Jekyll at its core is a text transformation engine. The concept behind the system is this: you give it text written in your favorite markup language, be that Markdown, Textile, or just plain HTML, and it churns that through a layout or series of layout files. Throughout that process you can tweak how you want the site URLs to look, what data gets displayed on the layout and more. This is all done through strictly editing files, and the web interface is the final product.

    A basic Jekyll site usually looks something like this:

    Read on →

  • Jekyll Template data

    Posted in • other at 2012-03-08 by lxj


    Jekyll traverses your site looking for files to process. Any files with [[YAML Front Matter]] are subject to processing. For each of these files, Jekyll makes a variety of data available to the pages via the Liquid templating system. The following is a reference of the available data.


    Variable Description
    site Sitewide information + Configuration settings from _config.yml
    page This is just the [[YAML Front Matter]] with 2 additions: url and content.
    content In layout files, this contains the content of the subview(s). This is the variable used to insert the rendered content into the layout. This is not used in post files or page files.
    paginator When the paginate configuration option is set, this variable becomes available for use.

    Read on →

© 2012