Sean Lou

专注前端开发

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

    Posted in • javascript at 2012-03-15 by lxj
    Tags:
    http://dayanjia.com/2010/10/9-confusing-naming-conventions-for-beginners-in-web-programming.html

    当人们一开始接触各种Web开发语言时,总会发现彻底搞懂不同语言的命名约定是一件很要命的事情。而且当开发者在争论什么才是最佳实践时,事情会变得更加让人困惑。为了让初学者更容易地在不同语言中过渡,这篇文章列出了一些常见的约定。

    1. 类属性名前加下划线

    如果你看到一个变量或者方法是以_开头的,其实这并不代表其幕后有什么猫腻。这仅仅是为了提醒开发者这个变量/属性/方法是私有的(private)或是受保护的(protected),它们不能从类的外部访问到。

    PHP方式

    >
    1
    2
    3
    4
    5
    6
    7
    
        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'};
          response.end(mustache.to_html(template,model));
        }
         
        exports.helloworld = helloworld;

    Read on →

  • Jekyll Pagination

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

    From:https://github.com/mojombo/jekyll/wiki/Usage

    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:

    _config.yml

    add the pagination setting:

    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
    Tags:Jekyll,data,

    From:https://github.com/mojombo/jekyll/wiki/Usage

    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 platformBlog 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
    Tags:Jekyll,data,
    From:https://github.com/mojombo/jekyll/wiki/Template-Data 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":http://wiki.github.com/shopify/liquid/liquid-for-designers. The following is a reference of the available data. h2. Global | *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