update
							parent
							
								
									34b45442c1
								
							
						
					
					
						commit
						fec4a26637
					
				
							
								
								
									
										57
									
								
								README.md
								
								
								
								
							
							
						
						
									
										57
									
								
								README.md
								
								
								
								
							|  | @ -575,29 +575,6 @@ Now, the `full_name` field in each array element will watch the `first_name` and | |||
| Watching fields by itself doesn't do anything.  For the example above, you need to tell JSON Editor that `full_name` should be `fname [space] lname`. | ||||
| JSON Editor uses a javascript template engine to accomplish this.  A barebones template engine is included by default (simple `{{variable}}` replacement only), but many of the most popular template engines are also supported: | ||||
| 
 | ||||
| *  ejs | ||||
| *  handlebars | ||||
| *  hogan | ||||
| *  markup | ||||
| *  mustache | ||||
| *  swig | ||||
| *  underscore >=1.7 (since 1.4.0, see also [#332](https://github.com/json-editor/json-editor/pull/332)) | ||||
| 
 | ||||
| You can change the default by setting `JSONEditor.defaults.options.template` to one of the supported template engines: | ||||
| 
 | ||||
| ```javascript | ||||
| JSONEditor.defaults.options.template = 'handlebars'; | ||||
| ``` | ||||
| 
 | ||||
| You can set the template engine on a per-instance basis as well: | ||||
| 
 | ||||
| ```js | ||||
| const editor = new JSONEditor(element,{ | ||||
|   schema: schema, | ||||
|   template: 'hogan' | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| Here is the completed `full_name` example using the default barebones template engine: | ||||
| 
 | ||||
| ```js+jinja | ||||
|  | @ -622,40 +599,6 @@ Here is the completed `full_name` example using the default barebones template e | |||
| } | ||||
| ``` | ||||
| 
 | ||||
| It is also possible to set the "template" property to a JavaScript callback function, defined under `window.JSONEditor.defaults.callbacks.template`. Inside the JavaScript callback, you have access to all the variables defined under the `watch` property + the current editor. | ||||
| 
 | ||||
| 
 | ||||
| Example Schema: | ||||
| ```js+jinja | ||||
| { | ||||
|   "type": "object", | ||||
|   "properties": { | ||||
|     "first_name": { | ||||
|       "type": "string" | ||||
|     }, | ||||
|     "last_name": { | ||||
|       "type": "string" | ||||
|     }, | ||||
|     "full_name": { | ||||
|       "type": "string", | ||||
|       "template": "callbackFunction", | ||||
|       "watch": { | ||||
|         "fname": "first_name", | ||||
|         "lname": "last_name" | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
| ``` | ||||
|  Example Callback function: | ||||
| ```js+jinja | ||||
| window.JSONEditor.defaults.callbacks.template = { | ||||
|   "callbackFunction": (jseditor,e) => { | ||||
|     return e.fname + " " + e.lname; | ||||
|   } | ||||
| }; | ||||
| ``` | ||||
| 
 | ||||
| ### Enum Values | ||||
| 
 | ||||
| Another common dependency is a drop down menu whose possible values depend on other fields.  Here's an example: | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue