CN109522018A - Page processing method, device and storage medium - Google Patents

Page processing method, device and storage medium Download PDF

Info

Publication number
CN109522018A
CN109522018A CN201811351835.6A CN201811351835A CN109522018A CN 109522018 A CN109522018 A CN 109522018A CN 201811351835 A CN201811351835 A CN 201811351835A CN 109522018 A CN109522018 A CN 109522018A
Authority
CN
China
Prior art keywords
node
attribute
module
page
template
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.)
Granted
Application number
CN201811351835.6A
Other languages
Chinese (zh)
Other versions
CN109522018B (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201811351835.6A priority Critical patent/CN109522018B/en
Publication of CN109522018A publication Critical patent/CN109522018A/en
Application granted granted Critical
Publication of CN109522018B publication Critical patent/CN109522018B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/14Tree-structured documents
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation
    • G06F40/154Tree transformation for tree-structured or markup documents, e.g. XSLT, XSL-FO or stylesheets

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Artificial Intelligence (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Stored Programmes (AREA)
  • Document Processing Apparatus (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

This application discloses a kind of page processing method, device and storage mediums.This method comprises: according to the view generation template character string of the page to be generated;The template character string is parsed, template tree is generated;The attribute for obtaining at least one node in the template tree constructs data structure associated with the data model of the page to be generated according to the attribute of at least one node;And tree construction is converted by the data structure, the first marking language document is generated according to the data model and the tree construction, and the page is generated according to the first marking language document.Using these technical solutions, the time efficiency of page development and maintenance and the resource utilization of Page handling device can be improved.

Description

Page processing method, device and storage medium
Technical field
This application involves field of computer technology more particularly to page processing methods, device and storage medium.
Background technique
With the rapid development of Internet service, present webpage becomes increasingly complex, and function is stronger and stronger, data volume It is gradually increased.In this case, when carrying out web front-end exploitation, the mode efficiency of directly operation DOM Document Object Model (DOM) is got over Come lower, the logic of JavaScript becomes increasingly complex, and causes the maintenance cost of website very high.
Currently, existing solution is formed in order to reduce the direct operation to DOM using JavaScript logic Virtual tree, the virtual tree after interface data is changed are compared to obtain difference, be then adjusted according to difference to interface.But It is, it is time-consuming all long in the exploitation and maintenance of webpage due to using JavaScript logic to form virtual tree.In addition, The time overhead of virtual tree comparison is also very big, even if treatment effeciency is repaired much worse than manually using the manner of comparison of circular recursion Change DOM.In consideration of it, how to improve the time efficiency of page development and maintenance is to need what is solved to ask when front end is developed Topic.
Summary of the invention
In view of this, can be improved page the embodiment of the invention provides a kind of page processing method, device and storage medium The resource utilization of the time efficiency and Page handling device of face exploitation and maintenance.
The technical scheme of the present invention is realized as follows:
The embodiment of the invention provides a kind of page processing methods, comprising:
According to the view generation template character string of the page to be generated;
The template character string is parsed, template tree is generated;
The attribute for obtaining at least one node in the template tree, according to the attribute of at least one node construct with to Generate the associated data structure of data model of the page;And
Tree construction is converted by the data structure, the first label language is generated according to the data model and the tree construction It says document, and the page is generated according to first marking language document.
The embodiment of the invention also provides a kind of Page handling devices, comprising:
Templating module, for the view generation template character string according to the page to be generated;
Parsing module, the template character string for generating to the templating module parse, and generate template tree;
Module is obtained, for obtaining the attribute of at least one node in the template tree that the parsing module generates;
Module is constructed, the attribute of at least one node for obtaining according to the acquisition module constructs and page to be generated The associated data structure of the data model in face;
Conversion module, the data structure for obtaining the building module are converted into tree construction;And
Generation module, the tree construction for being obtained according to the data model and the conversion module generate the first label language It says document, and the page is generated according to first marking language document.
The embodiment of the present invention provides a kind of computer readable storage medium again, is stored with computer-readable instruction, can be with At least one processor is set to execute method as described above.
Compared with prior art, method provided by the invention is reduced independent of fixed grammer and customized label The learning cost of developer, and grammer is flexible, implement easier;It will be counted when generating the first marking language document It is tree construction according to thaumatropy, improves the speed of renewal of the page, reduce the execution time of code;By template tree building with The associated data structure of the data model of the page to be generated, data model and DOM is direct-connected, and this binding can be significantly The processing time of less complex page, the efficiency of page development and maintenance is improved, while improving the money of Page handling device Source utilization rate.
Detailed description of the invention
For the clearer technical solution illustrated in the embodiment of the present invention, will make below to required in embodiment description Attached drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the invention, for For those of ordinary skill in the art, without creative efforts, it can also be obtained according to these attached drawings other Attached drawing.Wherein,
Fig. 1 is the structural schematic diagram of web front-end development system involved in one embodiment of the invention;
Fig. 2 is the exemplary process diagram of the page processing method of an embodiment according to the present invention;
Fig. 3 is the exemplary flow of the attribute of at least one node in the acquisition template tree of an embodiment according to the present invention Figure;
Fig. 4 generates showing for the first marking language document according to data model and tree construction for an embodiment according to the present invention Example property flow chart;
Fig. 5 is the exemplary process diagram of the page processing method of another embodiment according to the present invention;
Fig. 6 is the exemplary process diagram of the update mark Language Document of an embodiment according to the present invention;
Fig. 7 is the exemplary process diagram of the page processing method of another embodiment according to the present invention;
Fig. 8 is the structural schematic diagram of the Page handling device of an embodiment according to the present invention;
Fig. 9 is the structural schematic diagram of the Page handling device of another embodiment according to the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Site preparation description, it is clear that described embodiments are some of the embodiments of the present invention, instead of all the embodiments.Based on this hair Embodiment in bright, every other implementation obtained by those of ordinary skill in the art without making creative efforts Example, shall fall within the protection scope of the present invention.
The page processing method that the embodiment of the present invention is protected, can be applied to web front-end exploitation in, realize data with DOM direct-connected bi-directional data binding, the front end for being equally useful for Android operation system and IOS operating system are developed.
Fig. 1 is the structural schematic diagram of web front-end development system involved in one embodiment of the invention.As shown in Figure 1, web Front end development system 100 includes terminal device 101 and user 102.Operation has browser 103, browser on terminal device 101 It include the Page handling device 1031 and user interface 1032 that the embodiment of the present application is protected in 103.
According to an embodiment of the invention, developer carries out web site front end page using Page handling device 1031 Processing, specifically includes: according to the view generation template character string of the page to be generated;Template character string is parsed, mould is generated Plate tree;The attribute for obtaining at least one node in template tree, according to the building of the attribute of at least one node and the page to be generated The associated data structure of data model;And tree construction is converted by data structure, and generate according to data model and tree construction First marking language document.First marking language document, which is added in the page to be generated, can be obtained initial page, then exist It is shown in user interface.In this way, it is seen that the page when user opens browser.
According to an embodiment of the invention, when data model changes, it can be quick according to Page handling device 1031 Realize the update to the page.For example, Page handling device 1031 obtains the event of user's triggering by user interface 1032, at this moment It waits and is changed as the data model of data to be rendered, it, can be to the first label language by above-mentioned associated data structure Speech document is updated, and is obtained the second marking language document, is then rendered to the updated page, shows on a user interface.
Wherein, the terminal device 101 refers to the terminal device with data calculation processing function, including but not limited to (being equipped with communication module) smart phone, palm PC, tablet computer etc..Operation system is fitted on these communication terminals System, including but not limited to: Android operation system, Symbian operating system, Windows mobile operating system, Yi Jiping Fruit iPhone OS operating system etc..
Fig. 2 is the exemplary process diagram of the page processing method of an embodiment according to the present invention.This method is applied to browsing Device.As shown in Fig. 2, this method may include following steps:
Step 201, according to the view generation template character string of the page to be generated.
Step 202, template character string is parsed, generates template tree.
Step 203, obtain template tree at least one node attribute, according to the attribute of at least one node construct and to Generate the associated data structure of data model of the page.
Step 204, tree construction is converted by data structure, the first markup language text is generated according to data model and tree construction Shelves, and the page is generated according to the first marking language document.
Each step is described in detail below.
In step 201, according to the view generation template character string of the page to be generated.For example, the page to be generated is to use Family login page.The step may be implemented " templating ", that is, obtain the character string comprising variable and logic.Specifically, template word Symbol string includes scripting language sentence and markup language sentence.
In embodiments of the present invention, JavaScript language is used to carry out page development, markup language as scripting language For HyperText Markup Language (HTML).So, template character string generated be include JavaScript sentence and HTML language The mixed code of sentence.Since arbitrary JavaScript sentence can be write in template character string, can solve in the prior art The limitation that fixed labels and grammer can only be used, improves the efficiency of page development.
In view of being difficult to existing regular expression by the JavaScript sentence and output variable in template character string It distinguishes, in an embodiment of the present invention, when according to the view generation template character string of the page to be generated, specifically includes: setting First identifier is accorded with for marking scripting language sentence;Second identifier is arranged to accord with for label output when using markup language sentence Variable.
In specific application, first identifier symbol is<%%>, is carried out to JavaScript sentence using the grammer of<%%> It writes, such as<%if (name) { %><span>name cannot be empty<span><% } %>.Second identifier symbol is { { } }, right with its Output variable is identified, such as<span>{ { name } }</span>, indicate to export name in span.It distinguishes in this way, it is real Having showed has corresponding DOM to JavaScript sentence in virtual tree, and output variable can parse the attribute change for virtual tree.
For example, defining label div in following HTML code, wherein output variable class_name and name make It is indicated with { { } }, JavaScript sentence is indicated using<%%>.
In step 202, template character string is parsed, generates template tree.Due to template character in above-mentioned steps 201 String includes scripting language sentence and markup language sentence, then the template tree parsed includes scripting language sentence and dom tree.
For example, parsing using following getDomTree function to template character string (referring to tplHtml), template is obtained It sets (" root.firstElementChild " that refers to return).
In this way, the code in above-mentioned label div is resolvable to 3 nodes, obtained template tree is as follows:
▼Nodelist(3)[text,p.{{class_name}},text]
0:text
1:p. { { class_name } }
2:text
length:3
Wherein, text node indicated by text is described using JavaScript code.To including When the template character string of JavaScript sentence is parsed, application programming interfaces primary in JavaScript can be used (API), without carrying out complicated syntactic analysis, and the attribute of DOM can be directly obtained, i.e. the value of node.
In step 203, the attribute for obtaining at least one node in template tree is constructed according to the attribute of at least one node Data structure associated with the data model of the page to be generated.
Fig. 3 is the exemplary flow of the attribute of at least one node in the acquisition template tree of an embodiment according to the present invention Figure.As shown in figure 3, including the following steps:
Step 2031, template tree is traversed, at least one node is obtained.
In specific application, depth-first method can be used, recursive traversal template tree obtains each section in template tree Point.For example, the child node of tree is obtained with dom.childNodes, with the child node set of NodeList object return node.
Step 2032, classify at least one node traversed, judge whether each node is text node.
In this step, the type of each node is determined, judge whether the node is text node according to type.If so, holding Row step 2033, it is no to then follow the steps 2034.In specific application, nodeType return node type can be used to judge. When the type of a node of return is 3, determine that the node is text node;It otherwise, is non-textual node.
Step 2033, when a node is confirmed to be text node, according to the grammer of scripting language to text node Sentence analyzed, obtain text node at least one attribute-name and expression formula corresponding with the attribute-name.
In this step, for text node, the label and attribute of text node are obtained.JavaScript is carried out to attribute Syntactic analysis, whether the result after discriminatory analysis is JavaScript expression formula, if so, determining which included attribute has A bit, each attribute belongs to what kind of expression formula.
In analysis, expression formula corresponds at least one directive script.When analyzing expression formula, presets each script and refer to The script template of order;For each directive script, carried out according to sentence of the script template of the directive script to text node Matching, obtains the corresponding expression formula of the directive script.
Specifically, it when analyzing the JavaScript code of text node, needs that phase is arranged for each directive script The application method answered, i.e. script template.Table 1 is directive script example, title, meaning including multiple directive scripts and corresponding Script template.Wherein, these three instructions of v_if, v_elif, v_else are analyzed with canonical matching, and finally with { ending. V_if and v_elif be it is related, when finding " } else { " in JavaScript sentence, show the if of front and current Else be pairing, the condition of DOM will be parsed into the converse value of front if value behind such else, that is, negate.
1 directive script example of table
For each this instruction, since each represents one or more nodes, parsing when method similar to v_if, but It is two kinds of structures of each and for be analyzed respectively.In this regard, set script template is as follows:
In addition, bind instruction is that (such as bindtap is clicked, bindinput list is defeated for the attribute that has in the attribute bind to start Enter, the mouse events such as bindmouseup), due to be added in attribute, so being written into attr field.
Step 2034, when a node is confirmed to be non-textual node, the non-textual node is read from template tree Label and attribute.
For example, the use of the type of nodeType return node not being 3, then it is determined that the node is non-textual node.To this Non-textual node carries out HTML syntax analysis, can obtain the label (tagName) and attribute of the non-textual node (attributes)。
In this way, in step 203, being constructed according to the attribute of at least one node related to the data model of the page to be generated The data structure of connection, the data structure is direct-connected by data model and DOM, therefore, also referred to as direct-connected data structure.
In an embodiment of the present invention, the specific method for constructing above-mentioned data structure includes: in data structure, is each Text node constructs an element;It, will be with the attribute-name using the attribute-name of text node as key (key) in the element Corresponding expression formula and the corresponding directive script of the expression formula construct word associated with data model as value (value) Section.Wherein, the relationship of directive script and expression formula is also the combination of key assignments, i.e., directive script is as key, and expression formula is as value.
That is, according to the mode of the double-deck key assignments (key, (key, value)), the attribute write-in of text node is above-mentioned Associated field.When the data in data model change, corresponding node can be associated with by the attribute, in this way It is achieved that data and DOM's is direct-connected, therefore, above-mentioned field is alternatively referred to as direct-connected relationship field.
For example, the data structure established is array of data domArr, wherein label is building in the text node of " p " Direct-connected relationship field be relation field, including 2 attributes: first is that key is attribute-name " name ", value includes: script Instruct v_if, expression formula " $ { name } ";Directive script innerText, expression formula " name: $ { name } ";Second is that key is attribute Name " class_name ", value includes: directive script attr, expression formula " { ' class ': ' $ { class_name } ' } ".
For another example, when directive script is each, the relation field of building is as follows, wherein key is attribute-name " data ", value include: directive script each, expression formula " arr: ' data ', index: ' index ', item: ' value ' ".
In step 204, tree construction is converted by data structure, the first label language is generated according to data model and tree construction It says document, and the page is generated according to the first marking language document.
In this step, when generating the first marking language document, tree construction is converted by data structure.To the first of generation Marking language document is rendered, that is, produces the required page.
Specifically, converting DOM for data structure when generating html document.For example, the method for conversion is virtually The root node of one root converts tree construction root, following generation for the data structure data of input using getTree function Shown in code.
In this way, the tree construction generated is as follows, it is seen then that include direct-connected relationship field relation in the tree construction.
Fig. 4 generates showing for the first marking language document according to data model and tree construction for an embodiment according to the present invention Example property flow chart.As shown in figure 4, being included the following steps: using recursion method
Step 401, the element in html document is generated according to the label tag of tree construction interior joint.
For example, using document.createElement function in following example codes about render function Generate element, i.e. sentence var el=document.createElement (node.tag).
Step 402, updated domId is added in attribute.
Step 403, addition static attribute.
So-called static attribute refers in tree construction for the fixed value of node setting.These fixed values are the bases of nodal community This content is set dynamically on this basis to add dynamic attribute by variable.In following code, use SetAttribute function is arranged the static attribute of node.
Step 404, direct-connected relationship field relation is handled.
Direct-connected relationship field includes attribute-name, directive script, expression formula.Each directive script is run, operation result is obtained. It specifically includes, v_if, v_elif, v_else, if false is directly returned;InnerHTML utilizes template character string { };It is right In each, it can recycle according to the length of array and be added into element, wherein domid is arranged to ` $ { domid } _ $ { index } ` Carry out marker element.In this way when updating the page, only it is to be understood that changing the index of element in array, so that it may find out in DOM and want The element of update.
Step 405, Recursion process daughter element.
When the element generated in step 401 includes multiple daughter elements as father's element, father's element, can be used ForEach instruction carries out Recursion process to each daughter element, shown in following code.
The html document ultimately generated refers to the doc of return.The doc is rendered, available initial page, clear Look at device user interface on show.
In the above-described embodiments, by the view generation template character string according to the page to be generated, to template character string into Row parsing, generate template tree, obtain template tree at least one node attribute, according to the attribute of at least one node construct and The associated data structure of the data model of the page to be generated, converts tree construction for data structure, according to data model and tree The first marking language document of structural generation, can obtain following technical effect:
It 1), can be independent of fixed grammer and oneself due to writing arbitrary JavaScript sentence in template character string Therefore the label of definition reduces the learning cost of developer, and grammer is flexible, realizes without synthesis virtual tree manually Come easier.
2) when generating the first marking language document, tree construction is converted by data structure, benefit is when updating DOM It waits, this one-dimensional structure of arrays is easily operated and searches;And when generating html document, this tree construction is more easily generated, This improves the speed of renewal of the page, reduce the execution time of code.
3) associated with the data model of the page to be generated data structure is constructed by template tree, by data model and DOM is direct-connected, this binding can significantly less complex page the processing time, improve treatment effeciency, improve simultaneously The resource utilization of Page handling device.
Fig. 5 is the exemplary process diagram of the page processing method of another embodiment according to the present invention.As shown in figure 5, in Fig. 2 Shown on basis, further include following steps after the page that step 204 generates is initial page:
Step 501, whether monitored data model changes.
Data in data model are to monitor whether these data send variation for rendering the page, if changing, DOM is then updated, and then updates shown initial page.
In an embodiment of the present invention, the change that defineProperty function carrys out attribute in monitored data model can be used Change.Specifically, the set method in monitoring attribute.Rewriter of the set as attribute, once attribute is by assignment again, this set Method is invoked automatically.
In an alternative embodiment of the invention, setData function can be used, just updated when setting a property DOM, but call manually, the execution for updating the page can effectively be reduced manually by calling.
Step 502, when listening to data model and changing, according to the attribute of Modelandstructure of Data interior joint First marking language document is updated, obtains the second marking language document, and generate more according to the second marking language document The page after new.
The second obtained marking language document is rendered, the updated page can be obtained.
Fig. 6 is the exemplary process diagram of the update mark Language Document of an embodiment according to the present invention.As shown in fig. 6, packet Include following steps:
Step 601, the data field to change in data model is determined.
For example, key refers to the data field to change in following code.
Step 602, node associated with the attribute of the data field is determined in data structure.
For example, the attribute of the data field is " name ", data structure is the number for including direct-connected relationship field relation Group domArr (shown in following code), associated node are the node that label is " p ".
Step 603, element corresponding with the associated node is determined in the first marking language document.
For example, being " p " by label, the element of corresponding label " p " in html document doc can be determined, as to be updated Element.
Step 604, assignment is carried out to the element again according to the value of the data field to change, obtains the second label language Say document.
For example, the value of data field is indicated with value, tax is re-started by value of the getValue function to element Value, this completes the updates to element, to obtain new html document.
Through this embodiment, when data model changes, pass through the data model phase with the page to be generated of building Associated data structure is capable of determining that HTML element to be updated, can fast implement the update of the page in this way.
Fig. 7 is the exemplary process diagram of the page processing method of another embodiment according to the present invention.As shown in fig. 7, in Fig. 2 Shown on basis, further include following steps:
Step 701, the event triggered in the view of the page to be generated is obtained.
For example, this event (event) is to click (click) event, input (input) event etc..
Step 702, the first marking language document is updated according to the attribute of data structure interior joint and event, is obtained Second marking language document, and the updated page is generated according to the second marking language document.
It is instructed according to binding pre-set in the attribute of node, determines section associated with event in data structure Point;Element corresponding with the associated node is determined in the first marking language document;Call the corresponding event of the event Processing function handles event, obtains the second marking language document.The second obtained marking language document is rendered, The updated page can be obtained.
For example, binding instruction is the bind instruction provided in above-mentioned table 1, bind instruction is to be written in data structure In the attribute attr field of node.So, bind instruction is found in the data structure, so that it is determined that going out where bind instruction Node.
Through this embodiment, event generation results in interface and generates variation, when the event triggers, passes through the direct-connected number of building According to structure, the event of triggering is imported into HTML, to realize the update based on event.
Fig. 8 is the structural schematic diagram of the Page handling device 800 of an embodiment according to the present invention, which is applied to browsing In device.The Page handling device 800 includes:
Templating module 810, for the view generation template character string according to the page to be generated;
Parsing module 820, the template character string for generating to templating module 810 parse, and generate template tree;
Module 830 is obtained, the attribute of at least one node in the template tree for obtaining the generation of parsing module 820;
Construct module 840, the attribute of at least one node for being obtained according to module 830 is obtained, building with it is to be generated The associated data structure of the data model of the page;
Conversion module 850 is converted into tree construction for will construct the data structure that module 840 obtains;And
Generation module 860, the tree construction for being obtained according to data model and conversion module 850 generate the first markup language Document, and the page is generated according to the first marking language document.
In an embodiment of the present invention, template character string includes scripting language sentence and markup language sentence, templating mould Block 810 is used for, and setting first identifier is accorded with for marking scripting language sentence;Second identifier is arranged to accord with for using markup language Output variable is marked when sentence.
In an embodiment of the present invention, it obtains module 830 to be used for, traverses template tree, obtain at least one node;Judge institute State whether at least one node is text node;When a node is confirmed to be text node, according to the grammer of scripting language The sentence of text node is analyzed, at least one attribute-name of text node and corresponding with the attribute-name is obtained Expression formula.
In an embodiment of the present invention, Page handling device 800 further comprises:
Module 870 is monitored, whether is changed for monitored data model;
Update module 880, for when monitoring module 870 and listening to data model and change, according to data model and The attribute for the data structure interior joint that building module 840 obtains carries out the first marking language document that generation module 860 obtains It updates, obtains the second marking language document.
In an embodiment of the present invention, Page handling device 800 further comprises:
Monitor module 870, the event triggered in the view for obtaining the page to be generated;
Update module 880, the attribute and monitoring module of the data structure interior joint for being obtained according to building module 840 870 obtained events are updated the first marking language document that generation module 860 obtains, and obtain the second markup language text Shelves.
Fig. 9 is the structural schematic diagram of the Page handling device 900 of another embodiment according to the present invention.The Page handling device 900 include: processor 910, memory 920, port 930 and bus 940.Processor 910 and memory 920 pass through bus 940 interconnections.Processor 910 can send and receive data by port 930.Wherein,
Processor 910 is used to execute the machine readable instructions module of the storage of memory 920.
Memory 920 is stored with the executable machine readable instructions module of processor 910.The executable finger of processor 910 Module is enabled to include: templating module 921, parsing module 922, obtain module 923, building module 924, conversion module 925 and life At module 926.Wherein,
Templating module 921 can be with when being executed by processor 910 are as follows: according to the view generation template character of the page to be generated String;
Parsing module 922 can be with when being executed by processor 910 are as follows: the template character string that templating module 921 is generated into Row parsing, generates template tree;
Obtaining can be with when module 923 is executed by processor 910 are as follows: obtains in the template tree that parsing module 922 generates at least The attribute of one node;
Constructing can be with when module 924 is executed by processor 910 are as follows: according at least one node for obtaining module 923 and obtaining Attribute, construct associated with the data model of the page to be generated data structure;
Conversion module 925 can be with when being executed by processor 910 are as follows: will construct the data structure that module 924 obtains and be converted into Tree construction;
Generation module 926 can be with when being executed by processor 910 are as follows: the tree obtained according to data model and conversion module 925 The first marking language document of structural generation, and the page is generated according to the first marking language document.
In embodiments of the present invention, the executable instruction module of processor 910 further comprises: monitoring module 927 and more New module 928, wherein
Monitoring when module 927 is executed by processor 910 can be whether monitored data model changes;
Update module 928 can be to become when being executed by processor 910 when monitoring module 927 listens to data model When dynamic, the attribute of the data structure interior joint obtained according to data model and building module 924 generation module 926 is obtained the One marking language document is updated, and obtains the second marking language document.
In another embodiment, monitoring when module 927 is executed by processor 910 can be to obtain the view of the page to be generated The event triggered in figure;
Update module 928 can be to save when being executed by processor 910 in the data structure obtained according to building module 924 The event that the attribute and monitoring module 927 of point obtain is updated the first marking language document that generation module 926 obtains, and obtains To the second marking language document.
It can thus be seen that when storing the instruction module in memory 920 and being executed by processor 910, it can be achieved that preceding Templating module in each embodiment, parsing module are stated, module is obtained, building module, conversion module, generation module, monitors mould The various functions of block and update module.
In above-mentioned apparatus and system embodiment, modules and unit realize that the specific method of itself function is implemented in method It is described in example, which is not described herein again.
It, can also be in addition, each functional module in each embodiment of the present invention can integrate in one processing unit It is that modules physically exist alone, can also be integrated in one unit with two or more modules.Above-mentioned integrated list Member both can take the form of hardware realization, can also realize in the form of software functional units.
In addition, each embodiment of the invention can pass through the data processing by data processing equipment such as computer execution Program is realized.Obviously, data processor constitutes the present invention.In addition, being commonly stored data in one storage medium Processing routine is by directly reading out storage medium for program or by installing or copying to data processing equipment for program It stores in equipment (such as hard disk and/or memory) and executes.Therefore, such storage medium also constitutes the present invention.Storage medium can be with Use any kind of recording mode, such as paper storage medium (such as paper tape), magnetic storage medium (such as floppy disk, hard disk, flash memory Deng), optical storage media (such as CD-ROM), magnetic-optical storage medium (such as MO) etc..
Therefore, the invention also discloses a kind of storage mediums, wherein it is stored with data processor, the data processor For executing any embodiment of the above method of the present invention.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all in essence of the invention Within mind and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of the present invention.

Claims (15)

1. a kind of page processing method characterized by comprising
According to the view generation template character string of the page to be generated;
The template character string is parsed, template tree is generated;
The attribute for obtaining at least one node in the template tree, according to the attribute of at least one node building with it is to be generated The associated data structure of the data model of the page;And
Tree construction is converted by the data structure, the first markup language text is generated according to the data model and the tree construction Shelves, and the page is generated according to first marking language document.
2. according to the method described in claim 1, wherein, the template character string includes scripting language sentence and markup language language Sentence, it is described to include: according to the view generation template character string of the page to be generated
First identifier is arranged to accord with for marking the scripting language sentence;
Second identifier is arranged to accord with for marking output variable when using the markup language sentence.
3. according to the method described in claim 1, wherein, the attribute packet for obtaining at least one node in the template tree It includes:
The template tree is traversed, at least one described node is obtained;
Judge whether at least one described node is text node;
When a node is confirmed to be text node, divided according to sentence of the grammer of scripting language to text node Analysis obtains at least one attribute-name and expression formula corresponding with the attribute-name of text node.
4. according to the method described in claim 3, wherein, the expression formula corresponds at least one directive script;
The method further includes:
Preset the script template of each directive script;
The grammer according to scripting language analyzes the sentence of text node, obtains text node at least one Attribute-name and expression formula corresponding with the attribute-name include:
For each directive script, is matched, obtained according to sentence of the script template of the directive script to text node The corresponding expression formula of the directive script.
5. according to the method described in claim 3, wherein, the expression formula corresponds at least one directive script;
The attribute of at least one node according to constructs data structure associated with the data model of the page to be generated Include:
In the data structure, an element is constructed for each text node;
It, will expression formula corresponding with the attribute-name and the expression using the attribute-name of text node as key in the element The corresponding directive script of formula constructs field associated with the data model as value.
6. according to the method described in claim 1, further comprising:
Monitor whether the data model changes;
When listening to the data model and changing, according to the attribute of the data model and the data structure interior joint First marking language document is updated, the second marking language document is obtained.
It is described according to the data model and the data structure interior joint 7. according to the method described in claim 6, wherein Attribute is updated first marking language document, obtains the second marking language document and includes:
Determine the data field to change in the data model;
Node associated with the attribute of the data field is determined in the data structure;
Element corresponding with the associated node is determined in first marking language document;
Assignment is carried out to the element again according to the value of the data field to change, obtains second marking language document.
8. according to the method described in claim 1, further comprising:
Obtain the event triggered in the view of the page to be generated;
First marking language document is updated according to the attribute of the data structure interior joint and the event, is obtained Second marking language document.
9. according to the method described in claim 8, wherein, the attribute according to the data structure interior joint and the event First marking language document is updated, obtaining the second marking language document includes:
It is instructed, is determined associated with the event in the data structure according to binding pre-set in the attribute of node Node;
Element corresponding with the associated node is determined in first marking language document;
Assignment is carried out to the element again according to the processing result to the event, obtains second marking language document.
10. a kind of Page handling device characterized by comprising
Templating module, for the view generation template character string according to the page to be generated;
Parsing module, the template character string for generating to the templating module parse, and generate template tree;
Module is obtained, for obtaining the attribute of at least one node in the template tree that the parsing module generates;
Module is constructed, the attribute of at least one node for obtaining according to the acquisition module constructs and the page to be generated The associated data structure of data model;
Conversion module, the data structure for obtaining the building module are converted into tree construction;And
Generation module, the tree construction for being obtained according to the data model and the conversion module generate the first markup language text Shelves, and the page is generated according to first marking language document.
11. device according to claim 10, wherein the template character string includes scripting language sentence and markup language Sentence, the templating module are used for, and setting first identifier is accorded with for marking the scripting language sentence;Second identifier is arranged to accord with For marking output variable when using the markup language sentence.
12. device according to claim 10, wherein the acquisition module is used for, and traverses the template tree, described in acquisition At least one node;Judge whether at least one described node is text node;When a node is confirmed to be text node, Analyzed according to sentence of the grammer of scripting language to text node, obtain text node at least one attribute-name with And expression formula corresponding with the attribute-name.
13. device according to claim 10, further comprises:
Module is monitored, for monitoring whether the data model changes;
Update module, for when the monitoring module listens to the data model and changes, according to the data model The first marking language document that the attribute of the data structure interior joint obtained with the building module obtains the generation module It is updated, obtains the second marking language document.
14. device described in any one of 0 to 13 according to claim 1, further comprises:
Monitor module, the event triggered in the view for obtaining the page to be generated;
Update module, the attribute of the data structure interior joint for being obtained according to the building module and the monitoring module obtain Event the first marking language document that the generation module obtains is updated, obtain the second marking language document.
15. a kind of computer readable storage medium, which is characterized in that be stored with computer-readable instruction, at least one can be made Processor executes method as claimed in any one of claims 1-9 wherein.
CN201811351835.6A 2018-11-14 2018-11-14 Page processing method and device and storage medium Active CN109522018B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811351835.6A CN109522018B (en) 2018-11-14 2018-11-14 Page processing method and device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811351835.6A CN109522018B (en) 2018-11-14 2018-11-14 Page processing method and device and storage medium

Publications (2)

Publication Number Publication Date
CN109522018A true CN109522018A (en) 2019-03-26
CN109522018B CN109522018B (en) 2021-06-18

Family

ID=65777684

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811351835.6A Active CN109522018B (en) 2018-11-14 2018-11-14 Page processing method and device and storage medium

Country Status (1)

Country Link
CN (1) CN109522018B (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110244955A (en) * 2019-05-29 2019-09-17 广州至真信息科技有限公司 A kind of processing method of application, device, server and medium
CN110619096A (en) * 2019-06-12 2019-12-27 北京无限光场科技有限公司 Method and apparatus for synchronizing data
CN110955428A (en) * 2019-11-27 2020-04-03 北京奇艺世纪科技有限公司 Page display method and device, electronic equipment and medium
CN111259286A (en) * 2020-01-14 2020-06-09 上海英方软件股份有限公司 Universal WEB page layout generation device and method
CN111563363A (en) * 2020-05-12 2020-08-21 北京飞漫软件技术有限公司 Method for generating and analyzing hypertext markup language document content
CN111580830A (en) * 2020-05-12 2020-08-25 北京飞漫软件技术有限公司 Binding and analyzing method for hypertext markup language document element
CN111741257A (en) * 2020-05-21 2020-10-02 深圳市商汤科技有限公司 Data processing method and device, electronic equipment and storage medium
CN111857737A (en) * 2020-07-28 2020-10-30 苏州华望信息科技有限公司 Dynamic and static resource separation method based on SysML (SysML) model semantic web system
CN112650435A (en) * 2020-12-23 2021-04-13 平安普惠企业管理有限公司 Page content rolling processing method and device, computer equipment and storage medium
CN113961858A (en) * 2021-10-18 2022-01-21 广州创乐出海科技有限公司 Commodity page updating method and device, computer equipment and storage medium
CN114398578A (en) * 2021-12-23 2022-04-26 网易有道信息技术(北京)有限公司 Method for preprocessing HTML character string and related product
CN117453964A (en) * 2023-10-08 2024-01-26 北京融和云链科技有限公司 Template-based data structure acquisition and target template generation method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104281575A (en) * 2013-07-01 2015-01-14 上海缪思信息科技有限公司 Webpage data obtaining method and template engine
CN108572819A (en) * 2017-12-21 2018-09-25 北京金山云网络技术有限公司 Method for updating pages, device, terminal and computer readable storage medium
US20180307466A1 (en) * 2015-04-22 2018-10-25 Salesforce.Com, Inc. Systems and methods of implementing extensible browser executable components

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104281575A (en) * 2013-07-01 2015-01-14 上海缪思信息科技有限公司 Webpage data obtaining method and template engine
US20180307466A1 (en) * 2015-04-22 2018-10-25 Salesforce.Com, Inc. Systems and methods of implementing extensible browser executable components
CN108572819A (en) * 2017-12-21 2018-09-25 北京金山云网络技术有限公司 Method for updating pages, device, terminal and computer readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘烈毅: "基于jQuery框架的前端模板引擎的研究与实现", 《中国优秀硕士学位论文全文数据库》 *

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110244955B (en) * 2019-05-29 2023-04-18 广州至真信息科技有限公司 Application processing method, device, server and medium
CN110244955A (en) * 2019-05-29 2019-09-17 广州至真信息科技有限公司 A kind of processing method of application, device, server and medium
CN110619096A (en) * 2019-06-12 2019-12-27 北京无限光场科技有限公司 Method and apparatus for synchronizing data
CN110955428A (en) * 2019-11-27 2020-04-03 北京奇艺世纪科技有限公司 Page display method and device, electronic equipment and medium
CN111259286A (en) * 2020-01-14 2020-06-09 上海英方软件股份有限公司 Universal WEB page layout generation device and method
CN111563363A (en) * 2020-05-12 2020-08-21 北京飞漫软件技术有限公司 Method for generating and analyzing hypertext markup language document content
CN111580830A (en) * 2020-05-12 2020-08-25 北京飞漫软件技术有限公司 Binding and analyzing method for hypertext markup language document element
CN111563363B (en) * 2020-05-12 2023-08-15 北京飞漫软件技术有限公司 Method for generating and analyzing document content of hypertext markup language
CN111580830B (en) * 2020-05-12 2023-09-15 北京飞漫软件技术有限公司 Binding and parsing method for hypertext markup language document element
CN111741257A (en) * 2020-05-21 2020-10-02 深圳市商汤科技有限公司 Data processing method and device, electronic equipment and storage medium
CN111741257B (en) * 2020-05-21 2022-01-28 深圳市商汤科技有限公司 Data processing method and device, electronic equipment and storage medium
CN111857737A (en) * 2020-07-28 2020-10-30 苏州华望信息科技有限公司 Dynamic and static resource separation method based on SysML (SysML) model semantic web system
CN112650435A (en) * 2020-12-23 2021-04-13 平安普惠企业管理有限公司 Page content rolling processing method and device, computer equipment and storage medium
CN113961858A (en) * 2021-10-18 2022-01-21 广州创乐出海科技有限公司 Commodity page updating method and device, computer equipment and storage medium
CN114398578A (en) * 2021-12-23 2022-04-26 网易有道信息技术(北京)有限公司 Method for preprocessing HTML character string and related product
CN117453964A (en) * 2023-10-08 2024-01-26 北京融和云链科技有限公司 Template-based data structure acquisition and target template generation method and device
CN117453964B (en) * 2023-10-08 2024-04-30 北京融和云链科技有限公司 Template-based data structure acquisition and target template generation method and device

Also Published As

Publication number Publication date
CN109522018B (en) 2021-06-18

Similar Documents

Publication Publication Date Title
CN109522018A (en) Page processing method, device and storage medium
US10942708B2 (en) Generating web API specification from online documentation
US8799353B2 (en) Scope-based extensibility for control surfaces
US9009664B2 (en) Structural search of source code
US6973625B1 (en) Method for creating browser-based user interface applications using a framework
CN113126990B (en) Page development method, device, equipment and storage medium
WO2007144853A2 (en) Method and apparatus for performing customized paring on a xml document based on application
CN109145235B (en) Method and device for analyzing webpage and electronic equipment
CN109240692A (en) A kind of method for building up and system of the web database exploitation based on common template
CN106909361A (en) Web development approaches and device based on masterplate engine
US11580001B2 (en) Dynamic generation of instrumentation locators from a document object model
CN113377373A (en) Page loading method and device based on analysis engine, computer equipment and medium
CN110727429B (en) Front-end page generation method, device and equipment
CN114996619A (en) Page display method and device, computer equipment and storage medium
CN112463152A (en) Webpage adaptation method and device based on AST
CN110851136A (en) Data acquisition method and device, electronic equipment and storage medium
Bellucci et al. Automatic reverse engineering of interactive dynamic web applications to support adaptation across platforms
CN111078228A (en) Method and device for converting webpage into small program, server and storage medium
CN113849718A (en) Internet tobacco science and technology information automatic acquisition device, method and storage medium
CN113127776A (en) Breadcrumb path generation method and device and terminal equipment
CN103399746B (en) Information management system convenient to develop secondarily and development method
CN106991144B (en) Method and system for customizing data crawling workflow
CN112732254B (en) Webpage development method, webpage development device, computer equipment and storage medium
US7305667B1 (en) Call back structures for user defined DOMs
CN102981821A (en) Method and system for event broker

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant