Skip to content

Commit 21fbee9

Browse files
committed
Merge pull request expressjs#12 from gidenilson/gh-pages
translation
2 parents b147167 + 8391f3f commit 21fbee9

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
---
22
layout: page
3-
title: Developing template engines for Express
3+
title: Desenvolvendo template engines para Express
44
menu: advanced
5-
lang: en
5+
lang: pt-br
66
---
77

8-
# Developing template engines for Express
8+
# Desenvolvendo template engines para Express
99

10-
Use the `app.engine(ext, callback)` method to create your own template engine. `ext` refers to the file extension, `callback` is the template engine function which accepts the location of the file, the options object, and the callback function, as its parameters.
10+
Utilize o método `app.engine(ext, callback)` sua própria template entgine. `ext` se refere à extensão dos arquivos de template, `callback` é a função do template engine que recebe como parâmetros a localização do arquivo, o objeto `options`, e a fução callback.
1111

12-
The following is an example of implementing a very simple template engine for rendering ".ntl" files.
12+
A seguir temos um exemplo bem simples de uma template engine que renderiza arquivos com extensão ".ntl".
1313

1414
~~~js
15-
var fs = require('fs'); // this engine requires the fs module
16-
app.engine('ntl', function (filePath, options, callback) { // define the template engine
15+
var fs = require('fs'); // esta engine requer o módulo fs.
16+
app.engine('ntl', function (filePath, options, callback) { // define a template engine
1717
fs.readFile(filePath, function (err, content) {
1818
if (err) return callback(new Error(err));
19-
// this is an extremely simple template engine
19+
// esta é uma template engine extremamente simples
2020
var rendered = content.toString().replace('#title#', '<title>'+ options.title +'</title>')
2121
.replace('#message#', '<h1>'+ options.message +'</h1>');
2222
return callback(null, rendered);
2323
})
2424
});
25-
app.set('views', './views'); // specify the views directory
26-
app.set('view engine', 'ntl'); // register the template engine
25+
app.set('views', './views'); // especifica o dirétórios onde estão as views
26+
app.set('view engine', 'ntl'); // registra a template engine
2727
~~~
2828

29-
Your app will now be able to render ".ntl" files. Create a file named "index.ntl" in the views directory with the following content.
29+
Você poderá renderizar arquivos ".ntl". Crie uma arquivo chamado "index.ntl" no diretório views com o seguinte conteúdo.
3030

3131
~~~js
3232
#title#
3333
#message#
3434
~~~
35-
Then, create the following route in your app.
35+
Agora, crie a seguinte rota no seu app.
3636

3737
~~~js
3838
app.get('/', function (req, res) {
3939
res.render('index', { title: 'Hey', message: 'Hello there!'});
4040
})
4141
~~~
42-
On making a request to the home page, "index.ntl" will be rendered as HTML.
42+
43+
Fazendo-se uma requisição para a home page, "index.ntl" será renderizado como HTML.

0 commit comments

Comments
 (0)