mozilla / nunjucks

A powerful templating engine with inheritance, asynchronous control, and more (jinja2 inspired)
https://mozilla.github.io/nunjucks/
BSD 2-Clause "Simplified" License
8.58k stars 639 forks source link

Please add "hello world" example to the docs #1027

Open Ezra-Siton-UIX opened 7 years ago

Ezra-Siton-UIX commented 7 years ago

The site docs are really deep / well structure - but it is very hard to find a simple/practical (html combine with template engine) example like (Template - data - output):

$ var name = 'Frank';
<h1>
  Hello ${name}!
</h1>

output: <h1>Hello Frank!</h1>

In nunjucks docs I find simple example with this sentence "You usually won't use renderString" (Getting Started) - but why you don't add example of what I "usually should do" :) (codepen or any idea like this). This is really annoying.

Examples for the first page example of docs (Simple and clear for new users without "won't")

bcm0 commented 7 years ago

I very much support this idea! As a beginner I have a hard time getting a basic example up and running!

fdintino commented 6 years ago

I'm a bit unclear about your criticism of the current docs. Here's the full passage quoted (emphasis added):

You usually won't use renderString, instead you should write templates in individual files and use render. That way you can inherit and include templates. In this case, you need to tell nunjucks where these files live with the first argument of configure:

nunjucks.configure('views', { autoescape: true });
nunjucks.render('index.html', { foo: 'bar' });

That seems clear enough to me, but if you have a suggestion for how it could be improved I'd welcome a pull request.

fdintino commented 6 years ago

There's no need to be rude. First of all, it isn't "my documentation." I'm the current maintainer of the project, but I didn't write the docs. And I did not say "I understand it, so it's fine." I did say that it seems clear to me. That doesn't mean it's fine, it just means that I'm not the best person to add whatever clarity is needed. Your bulleted list of questions that should be answered is helpful, and is more actionable than the original ticket, which focused on the sentence about renderString vs render

as1ndu commented 5 years ago

Any updates on this?