[go: up one dir, main page]

CN113110845B - Plug-in system based on dynamic template compiling technology and implementation method thereof - Google Patents

Plug-in system based on dynamic template compiling technology and implementation method thereof Download PDF

Info

Publication number
CN113110845B
CN113110845B CN202110446048.5A CN202110446048A CN113110845B CN 113110845 B CN113110845 B CN 113110845B CN 202110446048 A CN202110446048 A CN 202110446048A CN 113110845 B CN113110845 B CN 113110845B
Authority
CN
China
Prior art keywords
code
python
template
compiling
pseudo
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.)
Active
Application number
CN202110446048.5A
Other languages
Chinese (zh)
Other versions
CN113110845A (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.)
Daguan Data Chengdu Co ltd
Original Assignee
Daguan Data Chengdu 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 Daguan Data Chengdu Co ltd filed Critical Daguan Data Chengdu Co ltd
Priority to CN202110446048.5A priority Critical patent/CN113110845B/en
Publication of CN113110845A publication Critical patent/CN113110845A/en
Application granted granted Critical
Publication of CN113110845B publication Critical patent/CN113110845B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

The invention relates to the technical field of low-code development platforms, and discloses a plug-in system based on a dynamic template compiling technology and an implementation method thereof, wherein the system comprises a form generator, a template code editor and a code generator, wherein the form generator is responsible for performing condition rendering on a basic component, processing basic code compiling control logic and then generating a JSON file for describing the whole form; the template code editor is responsible for establishing a Python code generation mapping, compiling a generation template of the Python code and generating a section of pseudo Python code; the code generator combines the pseudo Python code with the JSON file, and finally compiles the pseudo Python code into an executable Python code. The low-code development platform plug-in system provided by the invention is based on a smart dynamic template compiling technology, so that the safety of the whole plug-in system and the expandability of the whole low-code development platform are improved.

Description

Plug-in system based on dynamic template compiling technology and implementation method thereof
Technical Field
The invention relates to the technical field of low-code development platforms, in particular to a plug-in system based on a dynamic template compiling technology and an implementation method thereof.
Background
With the continuous popularization of low-code development platforms in the market in recent years, the market demand for related components of low-code systems becomes increasingly complex, and in order to ensure the system to be extensible, the traditional low-code development platform adopts a coding providing mode except for a built-in control, but the core value of the low-code development platform is lost, namely, the development cost is reduced.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: aiming at the existing problems, the plug-in system based on the dynamic template compiling technology and the implementation method thereof are provided, the plug-in system supports a user to visually arrange own controls with lower development cost through a compromised plug-in framework based on the dynamic template compiling technology, and the expandability of a low-code development platform can be greatly improved.
The technical scheme adopted by the invention is as follows:
in one aspect, the present invention provides a plug-in system based on dynamic template compilation technology, including: a form generator, a template code editor and a code generator;
the form generator is responsible for performing conditional rendering on the basic assembly, processing basic code compiling control logic and then generating a JSON file for describing the whole form;
the template code editor is responsible for establishing a Python code generation mapping, compiling a generation template of the Python code and generating a section of pseudo Python code;
and the code generator combines the pseudo Python code and the JSON file according to the JSON file generated by the form generator and the pseudo Python code generated by the template code editor, and finally compiles the pseudo Python code into an executable Python code.
Further, in the generation process of the Python code, the Python code is generated in a recursive mode, and in the generation process, state transfer between nodes is realized by using a closure.
Further, the code generator securely compiles the pseudo Python code into an executable legal Python code by injecting a JSON file using a sandbox environment of the nodjs virtual machine.
Further, the base component includes an input box, a check box, a color selector, a path selector, and a drop-down box.
Further, the form generator is responsible for performing a conditional rendering process on the base component, including: and realizing the detection of the conditional relationship when generating the JavaScript intermediate code and rendering the basic component by a dynamic template compiling technology.
On the other hand, the invention also provides a plug-in system implementation method based on the dynamic template compiling technology, which comprises the following steps:
step 1: performing conditional rendering on the basic component through a form generator, processing basic code compiling control logic through the form generator, and then generating a JSON file for describing the whole form;
step 2: establishing generation mapping of a Python code through a template code editor, compiling a generation template of the Python code, and generating a section of pseudo Python code;
and step 3: and transmitting the JSON file generated by the form generator and the pseudo Python code generated by the template code editor to a code generator, combining the pseudo Python code with the JSON file by the code generator, and finally compiling into an executable Python code.
Further, in the generation process of the Python code, the Python code is generated in a recursive mode, and in the generation process, state transfer between nodes is realized by using a closure.
Further, in the step 3, the code generator securely compiles the pseudo Python code into an executable legal Python code by injecting a JSON file using a sandbox environment of the nodjs virtual machine.
Further, the process of performing conditional rendering on the basic component by the form generator in step 1 includes: and realizing the detection of the conditional relationship when generating the JavaScript intermediate code and rendering the basic component by a dynamic template compiling technology.
Compared with the prior art, the beneficial effects of adopting the technical scheme are as follows: the invention greatly improves the expansibility of the low-code development platform by providing the plug-in system for the low-code development platform, and allows a user to make a user-defined control in a visual mode so as to meet complex scenes. The method realizes an ingenious dynamic template compiling technology, and has the characteristics of high performance, high safety and dynamic flexibility.
Drawings
FIG. 1 is a diagram of the operational relationships between the modules of the system.
Fig. 2 is a schematic view of a drop down frame assembly.
Fig. 3 is a schematic diagram of dependency description.
Detailed Description
The invention is further described below with reference to the accompanying drawings.
The embodiment of the invention provides a plug-in system based on a dynamic template compiling technology, which mainly comprises three modules: the working relation of the modules of the template code editor, the form generator and the code generator is shown in figure 1.
The form generator is mainly responsible for conditional rendering of the basic components, and meanwhile, in the rendering process, the form generator needs to process basic code compiling control logic, for example, the B component can be displayed only when the value of the A component is 'a', and finally, the form generator can generate a JSON (code logic structure) file for describing the whole form.
In the present embodiment, the basic components mainly include input boxes, check boxes, color selectors, path selectors, and drop-down boxes, which are all generated by the component factory.
In the following, taking the description of a drop-down box component as an example, it needs to provide the most basic parameters: the unique mark name, the initial value, the type, the title, the component element and the parameter params specific to the component, which is the data of the drop-down box, namely options, are defined, and finally a return is defined to represent the returned type, which can be used for the dependent type identification of the subsequent control.
In the process of conditional rendering, the dependency relationship of fields needs to be described and detected in a JSON file, and in the system, the detection of the conditional relationship is realized when a JavaScript code is generated and a form is rendered by selecting a dynamic compiling technology.
One of the simplest dependency relationships is described in FIG. 3, which shows the effect that when the radioKey selects an applet, the component corresponding to the inputKey will be displayed. The back processing logic is to compile a dynamic template in a regular mode, extract and replace the key word parameters to dynamically generate a JavaScript code, and then dynamically execute a conditional method in an eval ("code") mode.
The template code editor is responsible for establishing Python code generation relational mapping, that is, writing a Python code generation template, and the working principle of the template is basically consistent with the principle of conditional rendering in the form generator, as shown in fig. 3, except that there is no need to execute eval ('code'), but only generates intermediate code of Python code. Therefore, the template code editor ultimately generates a pseudo Python code (i.e., a Python code that cannot be executed).
And the code generator mixes the JSON file and the pseudo Python code together and finally compiles the mixed code into an executable Python code. The principle is that after a JSON file is injected into a sandbox environment of a Nodejs virtual machine, a pseudo Python code is safely compiled into an executable legal Python code.
In addition, for the whole Python code generation process, a section of Python code is abstracted into a bidirectional chain table tree, so that the Python code needs to be generated in a recursive manner, state transfer between nodes is realized by using a closure (namely, cross-scope transfer variable), and finally self-increment and retraction are realized, so that the generated Python code is ensured to be in accordance with the syntax specification.
The invention also provides a plug-in system implementation method based on the dynamic template compiling technology, which comprises the following steps:
step 1: performing conditional rendering on the basic component through a form generator, processing basic code compiling control logic through the form generator, and then generating a JSON file for describing the whole form;
step 2: establishing generation mapping of a Python code through a template code editor, compiling a generation template of the Python code, and generating a section of pseudo Python code;
and step 3: and transmitting the JSON file generated by the form generator and the pseudo Python code generated by the template code editor to a code generator, combining the pseudo Python code with the JSON file by the code generator, and finally compiling into an executable Python code.
Meanwhile, in the generation process of the Python code, the Python code is generated in a recursive mode, and state transfer between nodes is realized by using a closure in the generation process.
Specifically, in step 1 of the method, the process of performing conditional rendering on the basic component by the form generator includes: and realizing the detection of the conditional relationship when generating the JavaScript intermediate code and rendering the basic component by a dynamic template compiling technology.
Specifically, in step 3 of the method, the code generator safely compiles the pseudo Python code into an executable legal Python code by injecting a JSON file using a sandbox environment of the Nodejs virtual machine.
The invention is not limited to the foregoing embodiments. The invention extends to any novel feature or any novel combination of features disclosed in this specification and any novel method or process steps or any novel combination of features disclosed. Those skilled in the art to which the invention pertains will appreciate that insubstantial changes or modifications can be made without departing from the spirit of the invention as defined by the appended claims.

Claims (8)

1. A plug-in system based on dynamic template compilation technology, comprising: a form generator, a template code editor and a code generator;
the form generator is responsible for performing conditional rendering on the basic assembly, processing basic code compiling control logic and then generating a JSON file for describing the whole form;
the template code editor is responsible for establishing a Python code generation mapping, compiling a generation template of the Python code and generating a section of pseudo Python code;
the code generator combines the pseudo Python code with the JSON file according to the JSON file generated by the form generator and the pseudo Python code generated by the template code editor, and finally compiles the pseudo Python code into an executable Python code;
the form generator is responsible for carrying out a conditional rendering process on the basic component and comprises the following steps: the method comprises the steps of generating JavaScript intermediate codes through a dynamic template compiling technology and realizing detection of a condition relation when a basic component is rendered;
the processing logic of the dynamic template compiling technology is to perform dynamic template compiling in a regular mode, extract and replace a keyword parameter to dynamically generate a JavaScript code, and then dynamically execute a conditional method in an eval ("code") mode.
2. The plugin system based on dynamic template compilation technology of claim 1, wherein the Python code is generated in a recursive manner during generation of the Python code, and the state transfer between nodes is implemented using a closure during the generation.
3. The plugin system based on dynamic template compilation technology of claim 1, wherein the code generator is configured to securely compile a pseudo Python code into an executable legal Python code by injecting JSON files using a sandbox environment of a Nodejs virtual machine.
4. The system of claim 1, wherein the base component comprises an input box, a check box, a color selector, a path selector, and a drop-down box.
5. A plug-in system based on dynamic template compilation technology as claimed in claim 1 or 4, wherein the base component is generated by a component factory.
6. A plug-in system implementation method based on dynamic template compilation technology is characterized by comprising the following steps:
step 1: performing conditional rendering on the basic component through a form generator, processing basic code compiling control logic through the form generator, and then generating a JSON file for describing the whole form;
step 2: establishing generation mapping of a Python code through a template code editor, compiling a generation template of the Python code, and generating a section of pseudo Python code;
and step 3: transmitting the JSON file generated by the form generator and the pseudo Python code generated by the template code editor to a code generator, combining the pseudo Python code with the JSON file by the code generator, and finally compiling the pseudo Python code into an executable Python code;
the process of performing conditional rendering on the basic component by the form generator in the step 1 includes: the method comprises the steps of generating JavaScript intermediate codes through a dynamic template compiling technology and realizing detection of a condition relation when a basic component is rendered;
the processing logic of the dynamic template compiling technology is to perform dynamic template compiling in a regular mode, extract and replace a keyword parameter to dynamically generate a JavaScript code, and then dynamically execute a conditional method in an eval ("code") mode.
7. The method according to claim 6, wherein the Python code is generated recursively during the generation of the Python code, and the state transfer between the nodes is implemented using closure during the generation.
8. The method as claimed in claim 6, wherein in step 3, the code generator is configured to securely compile the pseudo Python code into the executable legal Python code by injecting JSON file through sandbox environment of the Nodejs virtual machine.
CN202110446048.5A 2021-04-25 2021-04-25 Plug-in system based on dynamic template compiling technology and implementation method thereof Active CN113110845B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110446048.5A CN113110845B (en) 2021-04-25 2021-04-25 Plug-in system based on dynamic template compiling technology and implementation method thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110446048.5A CN113110845B (en) 2021-04-25 2021-04-25 Plug-in system based on dynamic template compiling technology and implementation method thereof

Publications (2)

Publication Number Publication Date
CN113110845A CN113110845A (en) 2021-07-13
CN113110845B true CN113110845B (en) 2021-10-26

Family

ID=76719950

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110446048.5A Active CN113110845B (en) 2021-04-25 2021-04-25 Plug-in system based on dynamic template compiling technology and implementation method thereof

Country Status (1)

Country Link
CN (1) CN113110845B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103019684A (en) * 2012-11-20 2013-04-03 北京思特奇信息技术股份有限公司 Dynamic template-based business page configuring method
CN103500087A (en) * 2013-09-17 2014-01-08 福建亿榕信息技术有限公司 Code generation method and device based on maven plug-in and freemarker template
US8689189B1 (en) * 2008-02-15 2014-04-01 Amazon Technologies, Inc. Systems and methods for testing widgets
US8959427B1 (en) * 2011-08-05 2015-02-17 Google Inc. System and method for JavaScript based HTML website layouts
CN104503793A (en) * 2014-12-24 2015-04-08 风腾科技(北京)有限公司 Method for running and graphically analyzing codes in code practicing software
CN106371829A (en) * 2016-08-24 2017-02-01 北京邮电大学 Modularization thinking-based template framework design method and system
CN106873965A (en) * 2016-12-25 2017-06-20 北京通途永久科技有限公司 A kind of method suitable for the monitoring service class application dynamic construction page
CN109117119A (en) * 2018-07-02 2019-01-01 成都四方伟业软件股份有限公司 A kind of polymorphic component fusion method

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8689189B1 (en) * 2008-02-15 2014-04-01 Amazon Technologies, Inc. Systems and methods for testing widgets
US8959427B1 (en) * 2011-08-05 2015-02-17 Google Inc. System and method for JavaScript based HTML website layouts
CN103019684A (en) * 2012-11-20 2013-04-03 北京思特奇信息技术股份有限公司 Dynamic template-based business page configuring method
CN103500087A (en) * 2013-09-17 2014-01-08 福建亿榕信息技术有限公司 Code generation method and device based on maven plug-in and freemarker template
CN104503793A (en) * 2014-12-24 2015-04-08 风腾科技(北京)有限公司 Method for running and graphically analyzing codes in code practicing software
CN106371829A (en) * 2016-08-24 2017-02-01 北京邮电大学 Modularization thinking-based template framework design method and system
CN106873965A (en) * 2016-12-25 2017-06-20 北京通途永久科技有限公司 A kind of method suitable for the monitoring service class application dynamic construction page
CN109117119A (en) * 2018-07-02 2019-01-01 成都四方伟业软件股份有限公司 A kind of polymorphic component fusion method

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
"How to achieve high performance dynamic template rendering on flutter";light wine;《https://developpaper.com/how-to-achieve-high-performance-dynamic-template-rendering-on-flutter/》;20210203;第1-13页 *
"NodeJS沙箱逃逸&&vm";op_hxc;《http://www.cnblogs.com/ophxc/p/13663121.html》;20200815;第1-4页 *
"基于Vue.js的表单可视化构建系统的设计与实现";牛仁腾;《中国优秀博硕士学位论文全文数据库(硕士)信息科技辑》;20190515;第I138-762页 *
"基于数据驱动的动态Web模板技术设计与实现";刘放 等;《武汉科技大学学报》;20170228;第40卷(第1期);第70-75页 *

Also Published As

Publication number Publication date
CN113110845A (en) 2021-07-13

Similar Documents

Publication Publication Date Title
CN112100054B (en) A program static analysis method and system for data management and control
CN106293664A (en) Code generating method and device
CN107273117B (en) Programming-friendly agile code automatic generation system
CN104298921B (en) Animation source file security breaches inspection method and device
CN104932905A (en) Automatic code generation method from AADL to C language
CN111610744B (en) Logic control program generation method and system based on process time sequence and storage medium
CN102306102A (en) Method and device for automatically generating program file
CN107133038A (en) A kind of application program changes the method and its device of skin
US6405368B1 (en) Method for separate compilation of templates
Masiero et al. A reachability tree for statecharts and analysis of some properties
CN106681788A (en) Method and device for reducing application installation packages and electronic equipment
CN113377661A (en) Interface testing method and device, electronic equipment and storage medium
CN113110845B (en) Plug-in system based on dynamic template compiling technology and implementation method thereof
US20040154004A1 (en) Web application code conversion system
Miyazawa et al. Refinement-oriented models of Stateflow charts
CN105511935A (en) Resource index value acquiring method and device
CN107562428A (en) Rule-based adaptable software quick interface arrangement method and system
US20090064092A1 (en) Visual programming language optimization
Hemer et al. Supporting component-based reuse in CARE
Moutinho et al. Ecore representation for extending PNML for Input-Output Place-Transition nets
CN105867992A (en) Code compiling method and device
Szalay et al. Semi-Automatic Refactoring to C++ 20 Modules: A Semi-Success Story
Rencis Model transformation languages l1, l2, l3 and their implementation
US20250306903A1 (en) Method and Device for Update of Target File of Automotive Open System Architecture
Anureev Domain-specific transition systems and their application to a formal definition of a model programming language

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