Skip to content

031 Automatic import of custom code during compilation in JCB

Llewellyn van der Merwe edited this page Dec 19, 2018 · 23 revisions

Hi welcome to component Builder We've just added a very Smart new feature Two-component Builder That's Is cold Custom code You can find it here next to Dynamic get It's basically where it's stored You'd hardly never need to go in here Unless you wanna look at what is already been stored and make changes to that in the UI Most of the time you'll be doing the changes in your editor So you editor will be Basically where you will work So what is the purpose of this new feature The preacher is really there For those who are used to actually coding in another editor So what we can then say is let's say they create a component in component Builder And then once they've created it They basically do it compile Uninstall it onto the same website As component Builder To taste it And then during testing they are adding code into that Compiled version That are installed onto this website right Well the new feature could then On compilation extracted custom code Storage in this custom code area And added back into the component on the fly So I'm sure that is quite exciting Anyway let me do some demonstration give you some of the rules guidelines since there are some limb Limitations And then obviously this is still in beta there's quite a few things still to do But I would like to get it out there have you guys tested and get some feedback Okays I'm gonna compile the demo component Since most of you might already have this component installed And you can then use this is so the test area so will compile it there more component Ok then I'm gonna install it on to this current site Great Now I'm gonna go and give you An explanation of how to add Custom scripting to that component By going to an editor Ok so here in the editor you can see this is the root directory Of the website I'm gonna do something on the back in of the components I'll open administrative components And then there is the demo component And let's just go through it's main page Ok so its main index page And then let's see I'm gonna add some custom scripting here Just for the mistration No other way to add custom scripting there are some conventions and some Sort of regulations Let me first show you the conventions To insert custom scripting your user tag like so So in sleep You use Astrix instead of The Exes that are in the code so the code has the excess in it but the actual They would be with the Asterix So that will be to insert new code you use that that place holder and the beginning of the Area new then after a new line Yours insert your code and then at the end of the code you will insert this one to close the code Ok Then they are busy two ways Of adding code 1 is to insert code and wanted to replace existing code So in certain code with simply at the same line insert that code into the existing code Where is replace in code will literally remove the old code and add the new code in its place So these are the two conventions Once component builder ads the code back The dark will change inserted Insert will change to insert it And all have this new number at the end this number is actually referencing the ID of the Code in the system Now don't ever change this number or component Builder with think that it doesn't have one And it needs to be created So it will be an error it won't work so don't take this Number out Then It will add this at the end Now on other after compiling it and adding this string in it won't Compile it again because of these Opening and closing Brackets not being there Great torrent Lesser than signs They they are the ones that activate yet and makes makes it Basically be parsed again So when component builder prices the code back it looks like this When you then later come and want to change it again you would add this diamond in there And it will then update the existing Code in the database With the changes that you've made That's basically it there are a few limitations you cannot add Code Closer to its other than I would say 6 lines So if they r gonna B code Close to each other and it ends and starts within the parameter of 6 lines You end up with a problem So especially at the end I will demonstrate that somehow in in in a hour Actual doing of of this but the reason is component Build It doesn't only use the line In which this is found to remember where to place it But actually creates a sort of a fingerprint of the code above the insertion and the code Below the sin Session 2 Accurately inserted in the future So that code changes Send component builder will give you a notice and will not insert the code This is because of the nature of JVC It actually is constantly improving Sorry JC BMN it's constantly being improved and that therefore it's code is obviously moving a row Around quite a lot Now There was no other way for us to try and automate this Because if we use the line it could possibly cause an accident by overwriting code you You never intended it to overwrite So the only way we could solve this was creating what we call a fingerprint Few lines above the insertion or the replacement and a few lines below there that replacement Now I'll demonstrate this in our in our demonstration in a moment Just a heads up about that So just quickly a recap To insert new code you will use this To replace new code or for the first time you would use that Obviously at the end of the code you would add these Corresponding placeholders I'll put these this little block Into the comments of this tutorial So that if any of you need to copy it down you could just copy it from there Ok and so went component billiards it back It will look like this for the inserts inserted and this for the replaced I love you then come back Obviously all you need to do is just add that diamond in there For it to be updated in the database So let's see this in action So here we have that demo components Main Document Open So I'm gonna add some replacement tags here So there we go I'm basically not making any changes but I could I could add a few lines Maybe another comment hi it worked And No space there Let's do Echo Hi 8 Worked And that should do it so now this is just gonna replace this area So let's go to the compiler and compile the component See what happens Some in the compiler I'm simply gonna compile a component again Ok it successfully compiled Now before I install it I could do a check to see whether it actually did get the code from the component The way I'll do that is I'm doing to open custom codes in a new tab And now behold there is says component demo and the path in which the change was made And it it was it was a replacement so we can open that And there is the code that we want replaced Right And there is the hashtag For the start The fingerprint and the hashtag for the end The lines at cine replacement and everything seems quite great so I will we need to do on this Area is actually click install Then that'll be the compiled version then Now let's go back To the code So as you can see It actually inserted the code in the correct place it moved the other code down enough lines And it's changed it from replace to replaced And it added if the ID After it That sort of tigers it so I could go and say ok I don't actually want this in here like that Clicksafe And then go back to the compiler compile it again Amigo Install it again Go back here refresh this Hope she didn't change let me quickly go see why I forgot to add in the diamond right You want to change the code you need to ensure that you add this back in Otherwise it will not even look for it So we at that back in Let's try again Ok now it worked it updated the code in the database Select install it And it updated in the code So that's how easy it is to replace a certain section now let's look at inserting Now remember as I said Don't put code close to each other within at least eight lines So 1 2 3 4 5 6 7 8 I could actually from this line insert another set of other insert or replace Another section of code The reason is because the fingerprint that it creates Above the insertion It's sometimes up to 8 lines long Now It could happen that it actually uses from there And that could Possibly be an error when you make a change here It will think that this code is also been affected and it won't find it So that is one of the limitations that these codes insertions that you do either by replacing or inserting as Chunk of text script can only be inserted up to eight lines apart From each other So let's do an insertion over here Ok so we got that inserted there I did put a comment And let's save that And now let's compile Ok before we install it we can just again go check Whether everything was done as expected and yes the insertion was grab it was Added to the database and it is there Ok Does the has target obviously with insertion we only need where it starts not where it ends And so We can close that Now simply install that component Let's go look at the code Ok so it is added the replacement Script Change it from replace to replaced It's added the inserted script From insert to insert it Now if you want to make a change to it we're getting Just add these diamonds here Make out change Save the file of course and then Then let's compile Let's check whether the work was updated Great it's updated that work in the database So let's install the component Ok let's go look at the code again Wonderful it's added it back All seems well Now We are working on another part of this implementation that for if so for some reason this code above it Changes It will give you a notice On compilation That there is been a change to the fingerprint and it could not find the insertion area It will still at the code on the line number But it will be escaped So that it doesn't change or hurt any of the code that still there The same goes with replacement code Since it is replacing code It is a bit more tricky So we'll still added into the line but we will not remove the old code Anyway I'm still going to be working a bit on that it needs some fine tuning I would like your feedback if you think There's a better way I'm always open for ideas Realities We are very happy to announce that component builder can now Automatically extract custom code from your Component wow In development Will add a switch that when your ready to distribute your component You could simply say you know that it's no longer in production And then when you compile it will actually not add these placeholders Anymore Ok well thanks for watching Please give me your comments that get up There is actually an issue open there Called Automatic import of custom code during compilation And You'll see that Yeah there's quite a few been said you can simply add your your comments and feedback on to this ticket What is this issue it's issue 37 Services tutorial be on YouTube possibly by the time you build it's closed bye You're still welcome to go and make any comments on the closed issue if you like Anyway thanks for watching goodbye

Clone this wiki locally