CN104216926A - Page generating method, template engine and processor - Google Patents

Page generating method, template engine and processor Download PDF

Info

Publication number
CN104216926A
CN104216926A CN201310222086.8A CN201310222086A CN104216926A CN 104216926 A CN104216926 A CN 104216926A CN 201310222086 A CN201310222086 A CN 201310222086A CN 104216926 A CN104216926 A CN 104216926A
Authority
CN
China
Prior art keywords
masterplate
page
file
data
engine
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201310222086.8A
Other languages
Chinese (zh)
Inventor
郭铁志
张宝玉
马向晖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SHANGHAI MUSE INFORMATION SCIENCE & TECHNOLOGY Co Ltd
Original Assignee
SHANGHAI MUSE INFORMATION SCIENCE & TECHNOLOGY Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SHANGHAI MUSE INFORMATION SCIENCE & TECHNOLOGY Co Ltd filed Critical SHANGHAI MUSE INFORMATION SCIENCE & TECHNOLOGY Co Ltd
Priority to CN201310222086.8A priority Critical patent/CN104216926A/en
Publication of CN104216926A publication Critical patent/CN104216926A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/986Document structures and storage, e.g. HTML extensions

Abstract

The invention discloses a page generating method, a template engine and a processor applied to the template engine. The template engine is arranged on a server, responds to a first call instruction of a browser or a second call instruction of the server and reads page template data and a page template file in a JSON format in lightweight data exchange; the page template file in the JSON format is analyzed, and a template dynamic function corresponding to the page template file is obtained; the page template data are transmitted into the template dynamic function to generate a dynamic page. By means of the page generating method, the template engine and the processor, the same page generating scheme is adopted for generating the dynamic page in the two development directions of the browser and the server, and the situation that in the prior art, when two different schemes are adopted for generating pages in the two directions of the browser and the server, the page generating efficiency is reduced is avoided.

Description

A kind of page generation method, masterplate engine and processor
Technical field
The application relates to Computer Applied Technology field, particularly a kind of page generation method, masterplate engine and processor.
Background technology
At present, generating web page generally has two schemes, and a kind of is by the dynamic language in backstage as the support of the masterplate language such as jsp, php or asp, runs masterplate language at server end, is back in browser after server end produces dynamic page again; Another adopts front end javascript language dynamically to add html element by the DOM of browser, and generate dynamic page, this scheme is performed by the browser of client, and its development efficiency depends on the configuration of client.
In the scheme that above-mentioned two kinds of pages generate, for a certain page, generally only adopt a kind of generation scheme, the efficiency making to cause the page to generate because pattern is single is lower.
And if adopt above-mentioned two kinds of generation schemes for a certain page simultaneously, the code to two kinds generate scheme is needed all to safeguard, namely be after a kind of generation scheme carries out change exploitation to this page wherein, when another kind of generation scheme heavily changes, also need to rewrite the exploitation code write under current development mode, obviously have impact on the efficiency that the page generates, may occur that the page generates the skimble-scamble situation of effect simultaneously.
Therefore, need badly and a kind ofly can be applicable to generate the page on browser and server both direction and the technical scheme that can not affect efficiency of page generation.
Summary of the invention
Technical problems to be solved in this application are to provide a kind of page generation method, masterplate engine and processor, in order to solve in prior art when browser and server two kinds of directions carry out the generation page, affect the technical matters of development efficiency.
This application provides a kind of page generation method, be applied to masterplate engine, described masterplate engine is arranged on the server, and described method comprises:
In response to the first call instruction of browser, or the second call instruction of described server, read the page masterplate file of the exchanges data JSON form of page masterplate data and lightweight;
The page masterplate file of described JSON form is analyzed, obtains the masterplate kinematic function that described page masterplate file is corresponding;
Described page masterplate data are imported in described masterplate kinematic function, to generate dynamic page.
Said method, preferably, describedly to analyze described page masterplate file, the masterplate kinematic function obtaining this page masterplate file corresponding comprises:
Compiling is carried out to described page masterplate file and obtains at least one masterplate label;
Respectively each described masterplate label is resolved, obtain the javascript code snippet that each described masterplate label is corresponding;
All described javascript code snippets are combined, to obtain masterplate kinematic function corresponding to a described page masterplate file.
Said method, preferably, described obtain masterplate kinematic function corresponding to described page masterplate file after, described method also comprises:
Described masterplate kinematic function is placed in default function set;
Accordingly, after the page masterplate file of described reading page masterplate data and JSON form, described described page masterplate file analyzed before, described method also comprises:
The masterplate kinematic function that retrieval is corresponding with described page masterplate file in described function set;
If retrieve masterplate kinematic function, perform and described described page masterplate data are imported in described masterplate kinematic function, to generate the step of dynamic page, otherwise, perform and described described page masterplate file to be analyzed, obtain the step of masterplate kinematic function corresponding to described page masterplate file.
Said method, preferably, describedly carries out compiling to described page masterplate file and obtains at least one masterplate label, comprising:
Utilize regular expression to analyze in the masterplate character string of described page masterplate file, obtain the masterplate label that at least one is corresponding with described page masterplate file.
Present invention also provides a kind of masterplate engine, arrange on the server, described masterplate engine comprises:
Data reader, in response to the first call instruction of browser or the second call instruction of described server, reads the page masterplate file of page masterplate data and JSON form;
Data-analyzing machine, for analyzing the page masterplate file of described JSON form, obtains the masterplate kinematic function that described page masterplate file is corresponding;
Page builder, for importing in described masterplate kinematic function, to generate dynamic page by described page masterplate data.
Above-mentioned masterplate engine, preferably, described data-analyzing machine comprises:
Compiler, obtains at least one masterplate label for carrying out compiling to described page masterplate file;
At least one resolver, be respectively used to resolve each described masterplate label, obtain the javascript code snippet that each described masterplate label is corresponding, trigger described compiler all described javascript code snippets are combined, to obtain masterplate kinematic function corresponding to a described page masterplate file.
Above-mentioned masterplate engine, preferably, also comprises:
Function buffer, for obtain masterplate kinematic function corresponding to described page masterplate file at described data-analyzing machine after, is placed in default function set by described masterplate kinematic function;
Accordingly, described masterplate engine also comprises:
Functional query device, for read page masterplate file in described server and page masterplate data at described data reader after, before described data-analyzing machine is analyzed described page masterplate file, the masterplate kinematic function that retrieval is corresponding with described page masterplate stationery in described function set, if retrieve masterplate kinematic function, trigger described page builder, described page masterplate data are imported in described masterplate kinematic function, to generate dynamic page, otherwise, trigger described data-analyzing machine, described page masterplate file is analyzed.
Above-mentioned masterplate engine, preferably, described compiler specifically for:
Utilize regular expression to analyze in the masterplate character string of described page masterplate file, obtain the masterplate label that at least one is corresponding with described page masterplate file.
Present invention also provides a kind of processor, comprise the masterplate engine described in above-mentioned any one.
From such scheme, a kind of page generation method that the application provides, masterplate engine and processor, described method is applied to described masterplate engine, described masterplate engine arranges on server, described masterplate engine reads the page masterplate file of page masterplate data and JSON form in response to the first call instruction of browser or the second call instruction of described server, by analyzing the page masterplate file of JSON form, after obtaining masterplate kinematic function, page masterplate data are placed in masterplate kinematic function, thus generation dynamic page, realize on browser and server two developing way, adopt the same page to generate scheme and complete generation to dynamic page, to avoid in prior art in browser and server both direction, to adopt two kinds of different schemes to carry out the page when generating, reduce the situation of efficiency of page generation.
Accompanying drawing explanation
In order to be illustrated more clearly in the technical scheme in the embodiment of the present application, below the accompanying drawing used required in describing embodiment is briefly described, apparently, accompanying drawing in the following describes is only some embodiments of the application, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
The process flow diagram of a kind of page generation method embodiment one that Fig. 1 provides for the application;
The partial process view of a kind of page generation method embodiment two that Fig. 2 provides for the application;
The process flow diagram of a kind of page generation method embodiment three that Fig. 3 provides for the application;
Fig. 4 is another process flow diagram of the embodiment of the present application three;
The structural representation of a kind of masterplate engine embodiment four that Fig. 5 provides for the application;
The part-structure schematic diagram of a kind of masterplate engine embodiment five that Fig. 6 provides for the application;
The structural representation of a kind of masterplate engine embodiment six that Fig. 7 provides for the application;
Fig. 8 is another structural representation of the embodiment of the present application six;
The structural representation of a kind of processor embodiment seven that Fig. 9 provides for the application;
Figure 10 is the sequential chart realizing page generation in the embodiment of the present application seven;
Figure 11 is the examples of components figure in masterplate engine described in the embodiment of the present application seven;
Figure 12 is the application example logical architecture figure in the embodiment of the present application seven.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present application, be clearly and completely described the technical scheme in the embodiment of the present application, obviously, described embodiment is only some embodiments of the present application, instead of whole embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not making the every other embodiment obtained under creative work prerequisite, all belong to the scope of the application's protection.
With reference to figure 1, it illustrates the process flow diagram of a kind of page generation method embodiment one that the application provides, described method is applied to masterplate engine, and described masterplate engine is arranged on server, and namely the embodiment of the present application is applicable to the exploitation that browser and server two kinds of modes carry out the same page.In the embodiment of the present application, described masterplate engine is in response to the first call instruction of described browser, wherein, described first call instruction can be the script script tag call instruction of described browser, be: described browser can call described masterplate engine by script script tag, thus starts described masterplate engine.After the script label call instruction of described masterplate engine in response to described browser, described method can comprise the following steps:
Step 101: the page masterplate file reading the exchanges data JSON form of page masterplate data and lightweight.
Wherein, after or before the script label call instruction of described masterplate engine in response to described browser, before described step 101 implemented by described masterplate engine, described browser can in advance by page masterplate file that XMLHttpRequest load store stores on described server, and read by calling service logic the page masterplate data that described server stores, afterwards, perform described step 101 by described masterplate engine again, read described page masterplate data and described page masterplate file.And described page masterplate file can be realized by javascript.
Step 102: analyze the page masterplate file of described JSON form, obtains the masterplate kinematic function that described page masterplate file is corresponding.
Wherein, described step 102 can compile analyzer by the javascript in described masterplate engine and realize, and described page masterplate file is compiled into corresponding Dynamic Execution function, i.e. masterplate kinematic function.
Step 103: described page masterplate data are imported in described masterplate kinematic function, to generate dynamic page.
Wherein, described page masterplate data comprise required data parameters of adding in dynamic page leaved for development.
It should be noted that, described page masterplate data in advance is placed in the data storage device of described server as database, when the script label call instruction of described masterplate engine in response to described browser, perform before described step 101 reads described page masterplate data at described masterplate engine, first described browser acquires described page masterplate data by service logic interface, then performs described step 101 by described masterplate engine and read described page masterplate data.
It should be noted that, when the script label call instruction of described masterplate engine in response to described browser, after described step 103 generates described dynamic page, described method also comprises:
Described dynamic page is shown in described browser by amendment DOM innerHTML.
From such scheme, a kind of page generation method embodiment one that the application provides, the embodiment of the present application one is applied to described masterplate engine, described masterplate engine is arranged on the server, described masterplate engine reads the page masterplate file of page masterplate data and JSON form in response to the first call instruction of browser, by analyzing the page masterplate file of JSON form, after obtaining masterplate kinematic function, page masterplate data are placed in masterplate kinematic function, thus generation dynamic page, realize on the developing way of browser, adopt a kind of page to generate scheme and complete generation to dynamic page.
It should be noted that, masterplate engine in the embodiment of the present application one is except can in response to except the first call instruction of described browser, also the second call instruction of described server can be responded, wherein, described second call instruction can be the direct call instruction of described server, be: described server directly can call the masterplate engine be arranged on himself data storage device, thus start described masterplate engine.After the direct call instruction of described masterplate engine in response to described server, described masterplate engine is started described step 101 to described step 103, completes and generates dynamic page at described server end.
Wherein, the engine-operated required page masterplate data of described masterplate and page masterplate file are stored on the data storage device on described server.After or before the direct call instruction of described masterplate engine in response to described server, before described masterplate engine is implemented described step 101 by described startup of server, described server can obtain described page masterplate file by I/O equipment in advance, and obtain page masterplate data by calling service logic interface, afterwards, perform described step 101 by described masterplate engine again, read described page masterplate file and described page masterplate data.And described service logic interface can carry out data acquisition by the content in Query Database.
It should be noted that, when the direct call instruction of described masterplate engine in response to described server, after described step 103 generates described dynamic page, described method also comprises:
Described dynamic page is sent in described browser, triggers dynamic page described in described browser display.
It can thus be appreciated that, masterplate engine in the embodiment of the present application one is except realizing except dynamic page generation at described browser end in response to the first call instruction of browser, also can in response to the second call instruction of server, the page masterplate file of page masterplate data and JSON form is read by described masterplate engine, described masterplate engine is by analyzing the page masterplate file of JSON form, after obtaining masterplate kinematic function, page masterplate data are placed in masterplate kinematic function, thus generate dynamic page.Thus, the embodiment of the present application one achieves and on browser and server two developing way, to adopt the same page to generate scheme complete generation to same dynamic page, to avoid in prior art in browser and server both direction, to adopt two kinds of different schemes to carry out the page when generating, reduce the situation of efficiency of page generation.
With reference to figure 2, be the partial process view of a kind of page generation method embodiment two that the application provides, described step 102 can be realized by following steps:
Step 201: compiling is carried out to described page masterplate file and obtains at least one masterplate label.
Wherein, described step 201 can specific implementation in the following manner:
Utilize regular expression to analyze in the masterplate character string of described page masterplate file, obtain the masterplate label that at least one is corresponding with described page masterplate file.
It should be noted that, each described masterplate label has its different character type, comprises as masterplate labels such as expression formula, text, key word, embedded code and intrinsic functions.
Step 202: resolve each described masterplate label respectively, obtains the javascript code snippet that each described masterplate label is corresponding.
Wherein, above-mentioned steps 202 can realize in the following manner:
According to the masterplate definition rule pre-set, respectively each described masterplate label is resolved, obtain each self-corresponding javascript code snippet of each described masterplate label.
Step 203: combined by all described javascript code snippets, obtains the masterplate kinematic function that a described page masterplate file is corresponding.
Wherein, described page masterplate file is made up of JSON data, and JSON data are data layouts of a kind of plain text, and the masterplate character string of this data layout is directly changed into javascript code snippet, when realizing dynamic page and generating, significantly improve the development efficiency of the application to dynamic page.
With reference to figure 3, it illustrates the process flow diagram of a kind of page generation method embodiment three that the application provides, wherein, after described step 102, described method can also comprise the following steps:
Step S104: described masterplate kinematic function is placed in default function set.
Now, with reference to figure 4, be another process flow diagram of the embodiment of the present application three, after described step 101, before described step 102, described method can also comprise:
Step S105: the masterplate kinematic function that retrieval is corresponding with described page masterplate file in described function set.
Step S106: judge whether to retrieve masterplate kinematic function, if, perform described step 103, described page masterplate data are imported in described masterplate kinematic function, to generate dynamic page, wherein, masterplate kinematic function is now the masterplate kinematic function retrieved, otherwise, perform described step 102, described page masterplate file is analyzed, obtains the masterplate kinematic function that described page masterplate file is corresponding.
In such scheme, after first time is to the file analysis of page masterplate, the masterplate kinematic function obtained is carried out buffer memory, when the follow-up page carried out again generates task, after getting page masterplate file, first can retrieve in the function set of buffer memory and whether have ready-made masterplate kinematic function corresponding with current page masterplate file, if retrieve suitable masterplate kinematic function, then without the need to carrying out the analytical work of page masterplate file again, save system operation time, improve the work efficiency of page development.
With reference to figure 5, it illustrates the structural representation of a kind of masterplate engine embodiment four that the application provides, described masterplate engine is arranged on the server, and namely the embodiment of the present application is applicable to the exploitation that browser and server two kinds of modes carry out the same page simultaneously.In the embodiment of the present application, described masterplate engine is in response to the first call instruction of described browser, wherein, described first call instruction can be the script label call instruction of described browser, be: described browser can call described masterplate engine to described browser by script script tag, thus starts described masterplate engine.Described masterplate engine can also be called javascript masterplate engine, and described masterplate engine can comprise:
Data reader 501, for reading the page masterplate file of page masterplate data and JSON form.
Wherein, after or before the script label call instruction of described masterplate engine in response to described browser, before described data reader 501 is triggered execution, described browser can be stored in by XMLHttpRequest is pre-loaded the page masterplate file that described server stores in advance, and obtain by calling service logic the page masterplate data that described server stores in advance, afterwards, then by the data reader 501 in described masterplate engine described page masterplate data and described page masterplate file is read.And described page masterplate file is realized by javascript.
Data-analyzing machine 502, for analyzing the page masterplate file of described JSON form, obtains the masterplate kinematic function that described page masterplate file is corresponding.
Wherein, described data-analyzing machine 502 is connected with described data reader 501.Described data-analyzing machine 502 can compile analyzer by javascript and realize, and described page masterplate file is compiled into corresponding Dynamic Execution function, i.e. masterplate kinematic function.
Page builder 503, for importing in described masterplate kinematic function, to generate dynamic page by described page masterplate data.
It should be noted that, described page builder 503 is connected with described data-analyzing machine 502.
Wherein, described page masterplate data comprise required data parameters of adding in dynamic page leaved for development.
It should be noted that, described page masterplate data in advance is placed in the data storage device of described server as database, when the script label call instruction of described masterplate engine in response to described browser, before described data obtainer 501 reads described page masterplate data, first described browser acquires described page masterplate data by service logic interface, then reads described page masterplate data by the data reader 501 in described masterplate engine.
It should be noted that, when the script label call instruction of described masterplate engine in response to described browser, described page builder 503 is also for being shown in described browser by the dynamic page of generation.
From such scheme, a kind of masterplate engine embodiment four that the application provides, the embodiment of the present application four is applied to described masterplate engine, described masterplate engine is arranged on the server, described masterplate engine reads the page masterplate file of page masterplate data and JSON form in response to the first call instruction of browser, by analyzing the page masterplate file of JSON form, after obtaining masterplate kinematic function, page masterplate data are placed in masterplate kinematic function, thus generation dynamic page, realize on the developing way of browser, adopt a kind of page to generate scheme and complete generation to dynamic page.
It should be noted that, the masterplate engine of the embodiment of the present application four is except can in response to except the first call instruction of described browser, also the second call instruction of described server can be responded, wherein, described second call instruction can be the direct call instruction of described server, be: described server directly can call the masterplate engine be arranged on himself data storage device, thus start described masterplate engine.After the direct call instruction of described masterplate engine in response to described server, unit module in described masterplate engine such as data reader 501, data-analyzing machine 502 and page builder 503 are triggered operation successively, complete and generate dynamic page at described server end.
Wherein, the engine-operated required page masterplate data of described masterplate and page masterplate file are stored on the data storage device on described server.After or before the direct call instruction of described masterplate engine in response to described server, before data reader 501 in described masterplate engine is triggered and runs, described server can obtain described page masterplate file by I/O equipment in advance, and obtain page masterplate data by calling service logic interface, afterwards, then by the data reader 501 in described masterplate engine described page masterplate file and described page masterplate data are read.
It should be noted that, when the direct call instruction of described masterplate engine in response to described server, described page builder 503 also for being sent in described browser by the dynamic page of generation, triggers dynamic page described in described browser display.
It can thus be appreciated that, the masterplate engine of the embodiment of the present application four is except realizing except dynamic page generation at described browser end in response to the first call instruction of browser, also can in response to the second call instruction of server, the page masterplate file of page masterplate data and JSON form is read by described masterplate engine, described masterplate engine is by analyzing the page masterplate file of JSON form, after obtaining masterplate kinematic function, page masterplate data are placed in masterplate kinematic function, thus generate dynamic page.Thus, the embodiment of the present application four achieves and on browser and server two developing way, to adopt the same page to generate scheme complete generation to same dynamic page, to avoid in prior art in browser and server both direction, to adopt two kinds of different schemes to carry out the page when generating, reduce the situation of efficiency of page generation.
With reference to figure 6, be the part-structure schematic diagram of a kind of masterplate engine embodiment five that the application provides, wherein, described data-analyzing machine 502 can comprise:
Compiler 521, obtains at least one masterplate label for carrying out compiling to described page masterplate file.
Wherein, described compiler 521 can realize its function in the following manner:
Utilize regular expression to analyze in the masterplate character string of described page masterplate file, obtain the masterplate label that at least one is corresponding with described page masterplate file.
It should be noted that, each described masterplate label has its different character type, comprises as masterplate labels such as expression formula, text, key word, embedded code and intrinsic functions.
At least one resolver 522, be respectively used to resolve each described masterplate label, obtain the javascript code snippet that each described masterplate label is corresponding, trigger described compiler 521 all described javascript code snippets are combined, obtain the masterplate kinematic function that a described page masterplate file is corresponding.
It should be noted that, each described resolver 522 is connected with described compiler 521 respectively.
Wherein, the masterplate label of each described resolver 522 to its correspondence is resolved, and when obtaining corresponding javascript code snippet, can realize in the following manner:
According to the masterplate definition rule pre-set, the described masterplate label of this resolver 522 correspondence is resolved, obtain each self-corresponding javascript code snippet of this masterplate label.
It should be noted that, described page masterplate file is made up of JSON data, JSON data are data layouts of a kind of plain text, the masterplate character string of this data layout is directly changed into javascript code snippet, when realizing dynamic page and generating, significantly improve the development efficiency of the application to dynamic page.
With reference to figure 7, be the structural representation of a kind of masterplate engine embodiment six that the application provides, wherein, described masterplate engine can also comprise:
Function buffer 504, for obtain masterplate kinematic function corresponding to described page masterplate file at described data-analyzing machine 502 after, is placed in default function set by described masterplate kinematic function.
Wherein, described function buffer 504 is connected with described data-analyzing machine 502.
Now, with reference to figure 8, be another structural representation of the embodiment of the present application six, described masterplate engine also comprises:
Functional query device 505, for read page masterplate file in described server and page masterplate data at described data reader 501 after, before described data-analyzing machine 502 is analyzed described page masterplate file, the masterplate kinematic function that retrieval is corresponding with described page masterplate stationery in described function set, if retrieve masterplate kinematic function, trigger described page builder 503, described page masterplate data are imported in described masterplate kinematic function, to generate dynamic page, otherwise, trigger described data-analyzing machine 502, described page masterplate file is analyzed.
In such scheme, after first time is to the file analysis of page masterplate, the masterplate kinematic function obtained is carried out buffer memory, when the follow-up page carried out again generates task, after getting page masterplate file, first can retrieve in the function set of buffer memory and whether have ready-made masterplate kinematic function corresponding with current page masterplate file, if retrieve suitable masterplate kinematic function, then without the need to carrying out the analytical work of page masterplate file again, save system operation time, improve the work efficiency of page development.
With reference to figure 9, be the structural representation of a kind of processor embodiment seven that the application provides, described processor 901 can comprise the masterplate engine 902 in above-described embodiment described in any one.
Described masterplate engine 902 arranges on the server, wherein, when described masterplate engine 502 responds the first call instruction of described browser, namely described browser calls described masterplate engine 902 by script script tag, thus start described masterplate engine 902, and before described masterplate engine 902 runs, described browser is in advance by the pre-loaded page masterplate file be stored on described server of XMLHttpRequest, and obtain page masterplate data by calling service logic in advance, then trigger described masterplate engine 902 and run.
And when described masterplate engine responds the second call instruction of described server, namely described server directly calls described masterplate engine start, and before described masterplate engine 902 runs, described server reads described page masterplate file by I/O equipment in advance, and obtain page masterplate data by calling service logic in advance, then trigger described masterplate engine 902 and run.
Wherein, described masterplate engine 902, for reading the page masterplate file of the exchanges data JSON form of page masterplate data and lightweight; The page masterplate file of described JSON form is analyzed, obtains the masterplate kinematic function that described page masterplate file is corresponding; Described page masterplate data are imported in described masterplate kinematic function, to generate dynamic page.
It should be noted that, when the script label call instruction of described masterplate engine 902 in response to described browser, dynamic page, after completing dynamic page and generating, can be shown in described browser by amendment DOM innerHTML by described masterplate engine 902.
And when the direct call instruction of described masterplate engine 902 in response to described server, described dynamic page, after completing dynamic page and generating, can be sent in described browser, trigger dynamic page described in described browser display by described masterplate engine 902.
With reference to Figure 10, for realizing the sequential chart that the page generates in the embodiment of the present application seven, wherein, described realization side comprises browser or server, is described below to step each in described sequential chart:
1, trigger masterplate engine start, the page masterplate file described browser or server got in advance and page masterplate data import described masterplate engine into, are read described page masterplate file and described page masterplate data by described masterplate engine;
2, described template engine judges whether there is corresponding template kinematic function in the function set of buffer memory masterplate kinematic function, if do not had, then call compiler;
3, described compiler analyzes masterplate label corresponding in page masterplate file by adopting regular expression from the masterplate character string of page masterplate file, then calls the resolver that each masterplate label is corresponding;
4, each described resolver generates one section of javascript code snippet according to template definition;
5, described javascript code snippet is returned to described compiler by described resolver;
6, whole javascript code snippets is combined, obtain a masterplate kinematic function;
7, masterplate kinematic function is returned to described template engine;
8, described template engine puts into described function set template kinematic function, in order to subsequent calls to improve efficiency of page generation;
9, import page masterplate data into described masterplate kinematic function, obtain dynamic page;
10, the dynamic page obtained is returned to realization side.
With reference to Figure 11, be the examples of components figure in masterplate engine described in the embodiment of the present application seven, wherein, described masterplate engine, except comprising digital independent assembly, also comprises compiler as shown in Figure 11, buffer and multiple resolver.
Wherein, described processor 901 is the carrier running described masterplate engine 902, comprise computing machine, central processor CPU chip or other hardware processors, described masterplate engine 902 takies one piece of circuit on the pcb board of described processor 901, thus realizes the function of described masterplate engine 902.
In addition, with reference to Figure 12, for browser described in the embodiment of the present application seven, logical architecture figure between described server and described masterplate engine 902, described masterplate engine 902, described page masterplate file and described page masterplate data are all stored in described server.
When the script label call instruction of described masterplate engine 902 in response to described browser, described masterplate engine 902 is activated, the page masterplate data and page masterplate file that are got by described browser are in advance read by described masterplate engine 902, and then carry out data analysis, obtain dynamic page.Wherein, described browser by the pre-loaded page masterplate file be stored on described server of XMLHttpRequest, and obtains page masterplate data by calling service logic.
When the direct call instruction of described masterplate engine 902 in response to described server, described masterplate engine 902 is activated, read the page masterplate data and page masterplate file that are got by described server in advance by described masterplate engine 902, and then carry out data analysis, obtain dynamic page.Wherein, described server reads described page masterplate file by I/O equipment, and obtains page masterplate data by calling service logic.
It should be noted that, each embodiment in this instructions all adopts the mode of going forward one by one to describe, and what each embodiment stressed is the difference with other embodiments, between each embodiment identical similar part mutually see.
Finally, also it should be noted that, in this article, the such as relational terms of first and second grades and so on is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply the relation that there is any this reality between these entities or operation or sequentially.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thus make to comprise the process of a series of key element, method, article or equipment and not only comprise those key elements, but also comprise other key elements clearly do not listed, or also comprise by the intrinsic key element of this process, method, article or equipment.When not more restrictions, the key element limited by statement " comprising ... ", and be not precluded within process, method, article or the equipment comprising described key element and also there is other identical element.
Above a kind of page generation method provided by the present invention, masterplate engine and processor are described in detail, apply specific case herein to set forth principle of the present invention and embodiment, the explanation of above embodiment just understands method of the present invention and core concept thereof for helping; Meanwhile, for one of ordinary skill in the art, according to thought of the present invention, all will change in specific embodiments and applications, in sum, this description should not be construed as the restriction to the application.

Claims (9)

1. a page generation method, is characterized in that, is applied to masterplate engine, and described masterplate engine is arranged on server, and described method comprises:
In response to the first call instruction of browser, or the second call instruction of described server, read the page masterplate file of the exchanges data JSON form of page masterplate data and lightweight;
The page masterplate file of described JSON form is analyzed, obtains the masterplate kinematic function that described page masterplate file is corresponding;
Described page masterplate data are imported in described masterplate kinematic function, to generate dynamic page.
2. method according to claim 1, is characterized in that, describedly analyzes described page masterplate file, and the masterplate kinematic function obtaining this page masterplate file corresponding comprises:
Compiling is carried out to described page masterplate file and obtains at least one masterplate label;
Respectively each described masterplate label is resolved, obtain the javascript code snippet that each described masterplate label is corresponding;
All described javascript code snippets are combined, to obtain masterplate kinematic function corresponding to a described page masterplate file.
3. method according to claim 1, is characterized in that, described obtain masterplate kinematic function corresponding to described page masterplate file after, described method also comprises:
Described masterplate kinematic function is placed in default function set;
Accordingly, after the page masterplate file of described reading page masterplate data and JSON form, described described page masterplate file analyzed before, described method also comprises:
The masterplate kinematic function that retrieval is corresponding with described page masterplate file in described function set;
If retrieve masterplate kinematic function, perform and described described page masterplate data are imported in described masterplate kinematic function, to generate the step of dynamic page, otherwise, perform and described described page masterplate file to be analyzed, obtain the step of masterplate kinematic function corresponding to described page masterplate file.
4. method according to claim 2, is characterized in that, describedly carries out compiling to described page masterplate file and obtains at least one masterplate label, comprising:
Utilize regular expression to analyze in the masterplate character string of described page masterplate file, obtain the masterplate label that at least one is corresponding with described page masterplate file.
5. a masterplate engine, is characterized in that, arrange on the server, described masterplate engine comprises:
Data reader, in response to the first call instruction of browser or the second call instruction of described server, reads the page masterplate file of page masterplate data and JSON form;
Data-analyzing machine, for analyzing the page masterplate file of described JSON form, obtains the masterplate kinematic function that described page masterplate file is corresponding;
Page builder, for importing in described masterplate kinematic function, to generate dynamic page by described page masterplate data.
6. masterplate engine according to claim 5, is characterized in that, described data-analyzing machine comprises:
Compiler, obtains at least one masterplate label for carrying out compiling to described page masterplate file;
At least one resolver, be respectively used to resolve each described masterplate label, obtain the javascript code snippet that each described masterplate label is corresponding, trigger described compiler all described javascript code snippets are combined, to obtain masterplate kinematic function corresponding to a described page masterplate file.
7. masterplate engine according to claim 5, is characterized in that, also comprise:
Function buffer, for obtain masterplate kinematic function corresponding to described page masterplate file at described data-analyzing machine after, is placed in default function set by described masterplate kinematic function;
Accordingly, described masterplate engine also comprises:
Functional query device, for read page masterplate file in described server and page masterplate data at described data reader after, before described data-analyzing machine is analyzed described page masterplate file, the masterplate kinematic function that retrieval is corresponding with described page masterplate stationery in described function set, if retrieve masterplate kinematic function, trigger described page builder, described page masterplate data are imported in described masterplate kinematic function, to generate dynamic page, otherwise, trigger described data-analyzing machine, described page masterplate file is analyzed.
8. masterplate engine according to claim 6, is characterized in that, described compiler specifically for:
Utilize regular expression to analyze in the masterplate character string of described page masterplate file, obtain the masterplate label that at least one is corresponding with described page masterplate file.
9. a processor, is characterized in that, comprises the masterplate engine in the claims 5 to 8 described in any one.
CN201310222086.8A 2013-06-05 2013-06-05 Page generating method, template engine and processor Pending CN104216926A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310222086.8A CN104216926A (en) 2013-06-05 2013-06-05 Page generating method, template engine and processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310222086.8A CN104216926A (en) 2013-06-05 2013-06-05 Page generating method, template engine and processor

Publications (1)

Publication Number Publication Date
CN104216926A true CN104216926A (en) 2014-12-17

Family

ID=52098421

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310222086.8A Pending CN104216926A (en) 2013-06-05 2013-06-05 Page generating method, template engine and processor

Country Status (1)

Country Link
CN (1) CN104216926A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106569800A (en) * 2016-10-17 2017-04-19 北京小米移动软件有限公司 Front end interface generation method and apparatus
CN106599069A (en) * 2016-11-16 2017-04-26 上海斐讯数据通信技术有限公司 Method for providing page resource by cloud access controller and cloud access controller
CN107015819A (en) * 2016-01-27 2017-08-04 阿里巴巴集团控股有限公司 The method and apparatus of html template are updated in server end
CN107608691A (en) * 2017-08-18 2018-01-19 阿里巴巴集团控股有限公司 A kind of method for updating pages and device
CN108170430A (en) * 2017-12-26 2018-06-15 阿里巴巴集团控股有限公司 A kind of method and system of showing interface
CN109358845A (en) * 2017-12-27 2019-02-19 广州Tcl智能家居科技有限公司 Method, tool and the storage medium of JS code are write based on XMPP protocol
CN109739503A (en) * 2018-12-28 2019-05-10 深圳竹云科技有限公司 A kind of system generated based on the user demand dynamic control page
CN110297999A (en) * 2019-05-09 2019-10-01 京东方科技集团股份有限公司 A kind of web page template generation method and device, webpage loading method and front-end server and Website server
CN113722643A (en) * 2021-09-02 2021-11-30 山谷网安科技股份有限公司 Method and system for improving static generation efficiency of webpage in total station

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107015819A (en) * 2016-01-27 2017-08-04 阿里巴巴集团控股有限公司 The method and apparatus of html template are updated in server end
CN107015819B (en) * 2016-01-27 2020-11-13 阿里巴巴集团控股有限公司 Method and device for updating HTML (Hypertext markup language) template at server side
CN106569800A (en) * 2016-10-17 2017-04-19 北京小米移动软件有限公司 Front end interface generation method and apparatus
CN106569800B (en) * 2016-10-17 2020-10-23 北京小米移动软件有限公司 Front-end interface generation method and device
CN106599069A (en) * 2016-11-16 2017-04-26 上海斐讯数据通信技术有限公司 Method for providing page resource by cloud access controller and cloud access controller
CN107608691A (en) * 2017-08-18 2018-01-19 阿里巴巴集团控股有限公司 A kind of method for updating pages and device
CN108170430A (en) * 2017-12-26 2018-06-15 阿里巴巴集团控股有限公司 A kind of method and system of showing interface
CN109358845A (en) * 2017-12-27 2019-02-19 广州Tcl智能家居科技有限公司 Method, tool and the storage medium of JS code are write based on XMPP protocol
CN109739503A (en) * 2018-12-28 2019-05-10 深圳竹云科技有限公司 A kind of system generated based on the user demand dynamic control page
CN110297999A (en) * 2019-05-09 2019-10-01 京东方科技集团股份有限公司 A kind of web page template generation method and device, webpage loading method and front-end server and Website server
CN113722643A (en) * 2021-09-02 2021-11-30 山谷网安科技股份有限公司 Method and system for improving static generation efficiency of webpage in total station

Similar Documents

Publication Publication Date Title
CN104216926A (en) Page generating method, template engine and processor
CN104461484B (en) The implementation method and device of front-end template
US9703678B2 (en) Debugging pipeline for debugging code
CN104956362A (en) Analyzing structure of web application
CN102662646B (en) Sensing data disposal route and computing node
CN108984714A (en) Page rendering method, apparatus, electronic equipment and computer-readable medium
CN101165685A (en) Dynamic web page generation method and system
CN102693323B (en) Cascading style sheet resolving method, resolver, webpage presentation method and server
CN106021257A (en) Method, device, and system for crawler to capture data supporting online programming
CN109145235B (en) Method and device for analyzing webpage and electronic equipment
CN103500087A (en) Code generation method and device based on maven plug-in and freemarker template
CN112015430A (en) JavaScript code translation method and device, computer equipment and storage medium
CN104956375A (en) Presentation of user interface elements based on rules
Fenoy et al. ZOO-Project: the open WPS platform
CN112328219A (en) Service access processing method, device and system and computer equipment
CN113377661A (en) Interface testing method and device, electronic equipment and storage medium
CN110309631B (en) Programming language structure confusion processing method, intelligent terminal and storage medium
CN112965716B (en) Page processing method and device, electronic equipment and readable storage medium
CN111881043B (en) Page testing method and device, storage medium and processor
CN107180168A (en) File loading, generation method and device, and intelligent terminal
CN100383790C (en) HTTP web page dynamic outputting method and system
CN103473431A (en) Lightweight method for debugging hypertext preprocessor (PHP) program on line
CN111459810A (en) Method of constructing application program, programming apparatus, and computer-readable storage medium
CN111831277B (en) Virtual data generation method, system, device and computer readable storage medium
CN103677951A (en) Method and system for controlling executing process of JavaScript

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20141217