Personally, I think it is a waste of time to try and hide source code. A loop is a loop, a variable is a variable, etc. I understand that it might be advantageous to hide some of the business logic, but really, how often does one write code that has not already been written before? I can only think of a couple times that I have written code that I haven’t begged, borrowed, or stolen from somewhere. And even when I did, it hasn’t been anything so earth-shattering that I needed to hide it. And really, when it comes to web pages, there are only so many ways to skin a cat. For you PETA folks, just relax. It is only an expression.
At any rate, I have discovered that there are some ways of hiding your HTML from the casual user. Of course, even a moderately sophisticated user can still retrieve the source. The reason that I discovered this is because one of the projects I am working on requires that the view be dynamically generated. And it turns out that the YUI library is perfectly suited for this. Anyway, I thought simple example of some of what I have been working on was in order.
Now that we have the pointer to our div, we can add some content. Keeping it simple for now, we will just add a span with “Hello World” as the content. I know, the whole “Hello World” thing has been done to death, but so has “foo”. We need a few more lines of java script:
Rest of the lesson is here.