Nodejs in Visual Studio Code 13. Building a single-page application Scrat sample Digging

Source: Internet
Author: User

1. Start

Scrat the author said to get a very bunker example, sure enough to get out, if you want to learn and use Scrat, can start from the official example, is simply too convenient .

2.Scrat Example

Directory

Component_modules: Common Components

Components : System-Level components

Server: some services, no tube

Views : scrat.js,index.html and other Scrat framework content

Component.json: Scrat Eco-component configuration file  

fis-conf.js: FIS configuration file

Package.json: node configuration file

System-level components are separated into a single folder, including Js,css,handlebars ( what is handlebars?). Handlebars is a template that is built as a TPL attribute in a JS file, and then dynamically reads the data as it is rendered, eventually becoming the HTML we see.

Rendering of the skeleton

The code in Site.js and Site.handlebars is implemented as follows

  Menu.render,footer.render, a familiar rhythm, that's what the Express view engine says.

The composition of the skeleton

Open Scrat/components/site/site.handlebars, the system is composed of three parts of Site-menu,site-content,site-footer.

<div class= "Site Transition-all" >    <div class= "Site-menu transition-all" id= "Site-menu" ></div>    <div class= "Site-content transition-all" >        <div id= "site-views" class= "Site-views" >            {{# Each views}}            <div class= "Site-view" data-page= "{{@key}}" ></div>            {{/each}}        </div>    </div>    <div id= "Site-footer" class= "Site-footer transition-all" ></div></div>

Require

Require refers to files that are dependent

Each and extend are mapped by the name field of the Component.json under Scrat-team-each,scrat-team-extend.

{  ' name ': ' Each ',  ' repo ': ' Scrat-team/each ',  ' description ': ' A ForEach shim for both array and object ',  "Version": "0.1.0",  "keywords": ["Each", "ForEach"],  "Scripts": ["Index.js"],  "dependencies": {    " Scrat-team/type ":" 0.1.0 "  },  " license ":" MIT "}

  

  

3. End

Next combined with the official website of the examples and instructions, already have to be their own. NET front-end project is refactored into the east wind of the Scrat project, then there may be pits, first try it.

  Single page HTML technology flaw: May cause your website to be unable to crawl, I think this is also why use blink technology is Twitter, Facebook, these sites probably don't want to be crawled by Google content and sell ads.

Nodejs in Visual Studio Code 13. Building a single-page application Scrat sample Digging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.