HTML Layout/Templating - html

I am building a website where i'm looking to create html templates which contain placeholders where i'll be able to inject pages/content, menus, etc.... I really like AngularJS which has good support for this but am thinking that it might be a bit of an overkill for what i'm building. There is a chance some parts of the application will eventually be ripped out and run standalone and so dont want to tie the html/javascript to a library which requires so much framework specific syntax. Are there any other, simpler libraries, that will allow me to do this? thanks in advance
/Eric

KnockoutJS is pretty lightweight and also includes a templating feature.
I wouldn't just dismiss angularjs because it seems like a heavy framework. There are very simple ways to use it without using any of the "advanced" features like routing, creating services, creating directives, etc. You can simply have a controller and use the built in directives to do a lot of powerful things on a single page. Angular is also pretty small and is easily bootstrapped with the ng-app tag anywhere in your DOM.

Related

Umbraco vs DotNetNuke with own template

I would like to ask you to which one from this two systems i can easier implement my own template? I have ready template of my web page and i want to integrate it with one of this systems, my template contains some js code.
If you want to do it easy, I prefer to use Umbraco, because DNN for now, it is powerful and complex solution.And it will take more time for integration.
If your website really really simple, most probably, you can build website with Umbraco without any line of custom code c#.

Is there a convenient way to prototype future structure of View layer of MVC framework (Rails or like) on pure HTML?

My "Rails friends" have a situation when their UI designer is beginning his work on prototyping UI screens on his own - their Rails programmer is busy and is going to join this work later, probably much later.
I know, it is easy to ask UI designer the learn Rails rendering mechanism, so he could begin prototyping on Rails, but I am interested,
is it possible to setup views structure using partials (reusable pieces of HTML views) using just pure HTML, without any ruby code inside?
The only approach I see is to use SSI. Are there any other options?
What is needed is simply a possibility for one html-file could have a string like
<whatever include other.html ...>
which would include the contents of other.html inside its body.
This way, a future project can be divided logically on changeable/nonchangeable parts without any Ruby/Php code for partials.
UPDATE 1
The quoted wiki page about SSI has Client Side Includes section that suggests using object tag which seems to work
<object type="text/html" data="test.html"></object>
One suggestion is to use Sinatra, which is a simple and quick web framework for static sites.
It's easy to start using Sinatra even for a beginner. However, even if the UI man doesn't know and don't want to study any coding, he can still utilize it by planning the partial names and ask the developer to setup it for him. All he need to do later is to fill each blank templates and add JS CSS image assets.
Benefit of Sinatra:
Friendly to static sites
Simple to use
Lots of templating language to use, same as Rails
The partials/templates can be ported to Rails later with zero efforts!!!

HTML - writing vs generating code

I've had the chance to work with very different types of frameworks for web development. Somehow I can see that every framework tries to avoid me writing pure HTML code.
For example Spring has it's own tags, Struts comes with it's own tags also Zend and Codeigniter (PHP) have form helpers.
Does this mean I shouldn't just write HTML code myself or that it's not recommended? SHould I be using them? because they don't seem that intuitive, easy to manage and time saving as they intend.
You need to write your own HTML (and CSS) to define the overall structure and layout of your website design. Don't confuse this with time-saving features that eliminate the need to write repetitive HTML, such as form inputs and navigation menu items.
For example, under ASP.NET MVC you still need to get the bulk of your HTML into a MasterViewPage or Razor Layout, but when it comes to writing all of the form inputs you just need to put <%= Html.TextBoxFor( m => m.FirstName ) and it handles the rest, which saves you the trouble of writing boilerplate HTML for the <input /> element. It also helps avoid bugs (if you forget a name="" or `id=""`` attribute, for example, but in some frameworks it's essential to get reliable round-trip form data working.
I suggest you to manage your code by yourself if you don't have VERY good tools for generate it (for example Razor in ASP.NET MVC) which can do your code cleaner and more intuitive. In your case if You use Zend i suggest you to write your html in normal sites and only use generator for forms with Zenf_form. Becouse it is great.
Generated code services I have used generate ugly code that is hard to sift through at a later date.
writing the code and HTML yourself makes for a better structure and will not effect the way its run if that is what you are worried about and these languages are set to a standard.
Recommendation is to write the code where you can and generate code in areas you dont (or learn how to code it before you attempt it in test sheets).
I think it is a case by case basis.
These frameworks help you get rid of boilerplate code and write cleaner applications. You might also avoid some security problems by using them and you respect MVC.
There might be a performance penalty though so if you write a small application or you have certain requirements in speed you might be better without (some of) them.

Creating a web application, then adding Ajax to it?

I imagine there are many of you out there who have developed an application online which automates a lot of processes and saves people at your company time and money.
The question is, what are your experiences with developing that application, having it all set in place, then "spicing" it up with some Ajax, so it makes for a better user experience?
Also, what libraries would you suggest using when adding Ajax to an already-developed web application?
Lastly, what are some common processes you see in web applications that Ajax does well with? For example, auto-populating the search box as you type.
My preferred way of building Ajax-enabled applications is to build it the old-fashioned way where every button, link, etc. posts to the server, and then hijack all those button, link, etc. clicks to the Ajax functionality.
This ensures that my app is down-browser compatible, which is good.
It doesn't really matter which you use, unless you're trying to do something very specialized.
Here's a good list: http://code.google.com/apis/ajaxlibs/.
Yes, auto-completers are a pretty handy implementation of Ajax. It's also quite useful for data-intensive activities like populating drill-down data.
A lot of what you can do with these libraries isn't Ajax-specific, there is a lot of UI interaction that can benefit the user as well. You can do things like slideshows and lightboxes quite easily with many of these libraries.
Pick the one that you're comfortable with. The syntax they all use is a little different. Give a few a spin and try to build simple examples. Stick with the one you like.
Using ASP.NET Ajax to wrap a few chunks of code is an easy way to get going. But personally I prefer to use jQuery. You can easily add some simple Ajax calls with it to make the UI more responsive without the ASP.NET Ajax overhead.
If you are using ASP.NET to write your applications, adding AJAX using ASP.NET AJAX is very straightforward and in many places will not require you to change any code at all except add two controls to the pages you want to modify.
This works using partial page loads. The controls you have to add (off the top off my head) are called something like
<asp:ScriptManager
and
<asp:UpdatePanel
The biggest thing I use for AJAX is lists and search forms. Why? Because the overhead of loading an entire page when you are going though a list of, let's say, 200 records, it will get frustrating for a user to go though everything. However, it is important that if you click on a link in the page and then hit the back button or use a link at the top to return to the same page you were on.
For search forms, as you fill out the form I use AJAX queries to return the first few results and a number indicating how many records that were returned.
For AJAX frameworks, I use mootools. http://www.mootools.net.
Please ignore if not using ASP.NET. Your platform wasn't clear from your question.
Depending on when you created your web application, your web config file may need some tweaks to use ASP.NET Ajax. The easiest way to see is to create a new web site with the ASP.NET Ajax template and compare the web config, copying over configuration items as needed to bring the old one up to date.
If "spicing it up" is all you're after then develop the fully functional app without AJAX first. From here you can unobtrusively add AJAX functionality and ensure that the app degrades well for non JavaScript-enabled browsers.
I've started using jQuery for JavaScript on my site. It takes away all the worry of cross-browser JavaScript differences - things like class and classname, and getElementById. It also includes some very handy and simple functionality for AJAX postbacks. It's very easy to learn and extremely lightweight when used well.
I've seen some good use of AJAX right here on Stack Overflow, things like the tag selector and the question lookup when you type a question title. I think these simple things work best; we're just adding to the user experience with small additions to functionality that are intuitive, we're not flooding the screen with drag/drop handles etc.
I would differ from the first poster. Adding Ajax isn't always as easy as 1,2,3. It really depends on what you are after.
Adding things such as a colour animation can be made fairly easy, but if you are after things such as auto populating a text box, this requires extra code. It's not as easy as adding just something client side. You would also need to add in server-side support to fetch the partial query results.
Going beyond that, it can become even more complex keeping your client-side script in sync with server-side support.
But with the spirit of simplicity in mind there are libraries you can use to 'spice' up a website with animations and other eyecandy that can be implemented fairly easily which have been mentioned already.
I've often had to Ajax-enable an old-fashioned ASP.NET 2.0 sites. The easiest way I've found to do that is to create a new Ajax-enabled site and copy and paste certain sections of the web.config into your old project's web.config.
Just compare the two and see what's missing in your old one. You'll obviously also need to add references to AjaxExtensions and AjaxControlToolkit.

Does Django have HTML helpers?

Does Django have any template tags to generate common HTML markup? For example, I know that I can get a url using
{% url mapper.views.foo %}
But that only gives me the URL and not the HTML code to create the link. Does Django have anything similar to Rails' link_to helper? I found django-helpers but since this is a common thing I thought Django would have something built-in.
No it doesn't.
James Bennett answered a similar question a while back, regarding Rails' built-in JavaScript helpers.
It's really unlikely that Django will ever have 'helper' functionality built-in. The reason, if I understand correctly, has to do with Django's core philosophy of keeping things loosely coupled. Having that kind of helper functionality built-in leads to coupling Django with a specific JavaScript library or (in your case) html document type.
EG. What happens if/when HTML 5 is finally implemented and Django is generating HTML 4 or XHTML markup?
Having said that, Django's template framework is really flexible, and it wouldn't be terribly difficult to write your own tags/filters that did what you wanted. I'm mostly a designer myself, and I've been able to put together a couple custom tags that worked like a charm.
The purpose of helpers is not, as others here imply, to help developers who don't know how to write HTML. The purpose is to encapsulate common functionality -- so you don't need to write the same thing a thousand times -- and to provide a single place to edit common HTML used throughout your app.
It's the same reason templates and SSI are useful -- not because people don't know how to write the HTML in their headers and footers, but sometimes you want to write it just once.
EG. What happens if/when HTML 5 is
finally implemented and Django is
generating HTML 4 or XHTML markup?
Same thing that happens when HTML 5 is implemented and all your templates are written in repetitive HTML, except a lot easier.
The other posts have already answered the question, linking to the docs on custom template tags; you can use tags and filters to build your own, but no, there aren't any built in.
it doesnt look like they're built in but here's a couple snippets. it looks like it'd be pretty easy to create these helpers:
http://www.djangosnippets.org/snippets/441/
Here is a list of all template tags and filters built into Django. Django core doesn't have as much HTML helpers as Rails, because Django contributors assumed that web developer knows HTML very well. As stated by saturdaypalace, it's very unlikely for AJAX helpers to be added to Django, because it would lead to coupling Django with a specific JavaScript library.
It's very easy to write your own template tags in Django (often you need just to define one function, similiar to Rails). You could reimplement most of Rails helpers in Django during a day or two.
I bet if there would be any consent of what is common html, there would be helpers module too, just for completeness (or because others have it). ;)
Other than that, Django template system is made mostly for HTML people, who already know how to write p, img and a tags and do not need any helpers for that. On the other side there are Python developers, who write code and do not care if the variable they put in context is enclosed by div or by span (perfect example of separation of concerns paradigm). If you need to have these two worlds to be joined, you have do to it by yourself (or look for other's code).
This won't answer directly to the question, but why not using foo in template then?