Bản mẫu:Lưu ý chỗ thử bản mẫu

Tài liệu bản mẫu[xem] [sửa] [lịch sử] [làm mới]

Đây là bản mẫu {{lưu ý chỗ thử bản mẫu}}.

Nó có thể được đặt trên các trang bản mẫu /sandbox. Nó cũng phát hiện khi nó không nằm trên trang /sandbox và sau đó không hiển thị gì cả, do đó nó có thể được để lại trong mã khi được sao chép và dán vào bản mẫu chính. (Mặc dù hầu hết người dùng xóa thông báo sandbox khi họ sao chép mã từ /sandbox vào bản mẫu chính. Nhưng hãy cẩn thận, nếu tham số notice-not-sandbox đã được sử dụng thì thông báo sandbox phải được sao chép với phần còn lại của mã bản mẫu. Xem thêm bên dưới.)

Để tìm hiểu thêm về cách sử dụng trang con bản mẫu /sandbox và /testcases, hãy xem Wikipedia:Template sandbox and test cases.

Ví dụ đơn giản sửa

<!-- template code --><noinclude>
{{lưu ý chỗ thử bản mẫu}}
</noinclude>

Lưu ý! Mã bản mẫu phải bắt đầu trực tiếp trước và chạm vào tag <noinclude>. Bất kỳ khoảng trống hoặc dòng mới nào giữa mã bản mẫu và tag <noinclude> có thể khiến bản mẫu hiển thị không gian không mong muốn hoặc dòng mới khi được sử dụng.

Tên "/sandbox" và "/testcases" không chuẩn sửa

bản mẫu này sử dụng đối sánh phân biệt chữ hoa chữ thường, vì vậy sẽ khớp "/Sandbox", "/SandBox", "/sAnDbOx" vv... không có sự trợ giúp đặc biệt.

Nếu trang /sandbox có tên khác, ví dụ "/sandbag", thì bạn cần thông báo cho hộp cát thông báo tên của trang, để nó biết thời điểm hiển thị và khi nào không hiển thị chính nó. Như sau:

<!-- Template code --><noinclude>
{{lưu ý chỗ thử bản mẫu | subpage-name=sandbag }}
</noinclude>

Nếu trang testcases có tên khác, điều này có thể được xác định bằng tham số testcase-name:

<!-- Template code --><noinclude>
{{lưu ý chỗ thử bản mẫu | testcases-name=testbox}}
</noinclude>

Với điều kiện chỉ có một sandbox hoặc trang testcases được sử dụng cho trang chính cụ thể, một tùy chọn khác là di chuyển trang sandbox thành tên "/sandbox" chuẩn hoặc testcases thành "/testcases". Điều đó có thể thích hợp hơn vì các bản mẫu và công cụ khác cũng giả định rằng sandbox sử dụng tên đó, chẳng hạn như {{documentation}}.

Hiển thị và ẩn những thứ khác sửa

Thông báo sandbox cũng có thể giúp hiển thị và ẩn những thứ khác tùy thuộc vào việc phát hiện nó có nằm trên trang /sandbox hay không. Như thế này:

<!-- Template code --><noinclude>
{{lưu ý chỗ thử bản mẫu
| notice-for-sandbox = Văn bản hiển thị trên trang /sandbox.
| notice-not-sandbox = Văn bản sẽ hiển thị trên các trang khác.
}}
<!-- Text for all pages goes here -->
</noinclude>

Ví dụ về bản mẫu bảo vệ sửa

The notice-not-sandbox parameter can for instance be used so a protection template can be placed already in the /sandbox version of the code. (See also Wikipedia:Protection policy.) Like this:

<!-- Template code --><noinclude>
{{Lưu ý chỗ thử bản mẫu
| notice-not-sandbox = {{pp-semi-template|small=yes}}
}}</noinclude>

Documentation example sửa

Some templates have their documentation on a separate /doc page, and then show that documentation in a green doc box below the template code by using the {{documentation}} template. (See also Wikipedia:Template documentation.) Then place the sandbox notice like this:

<!-- Template code --><noinclude>
{{Lưu ý chỗ thử bản mẫu}}
{{documentation}}
<!-- Please add this template's categories to the /doc subpage - thanks! -->
</noinclude>

Super deluxe example sửa

This example handles both a protection template and a green doc box from a /doc page at the same time. (See also Wikipedia:Protection policy and Wikipedia:Template documentation.) Like this:

<!-- Template code --><noinclude>
{{Lưu ý chỗ thử bản mẫu
| notice-for-sandbox = Text that shows on the /sandbox page.
| notice-not-sandbox = {{pp-semi-template|small=yes}}
}}
{{documentation}}
<!-- Please add this template's categories to the /doc subpage - thanks! -->
</noinclude>

Copy, paste & delete sửa

The following "complete" example can be used to copy and paste into your template, then delete the parts you don't need:

<!-- Template code --><noinclude>
{{Lưu ý chỗ thử bản mẫu
| notice-for-sandbox =
| notice-not-sandbox =
<!-- Protection templates as big message boxes -->
{{pp-dispute}}
{{pp-office}}
{{pp-move}}
{{pp-protected}}
{{pp-template}}
{{pp-usertalk}}
{{pp-vandalism}}
{{pp-semi-protected}}
{{pp-semi-sock}}
{{pp-semi-spambot}}
{{pp-semi-template}}
{{pp-semi-usertalk}}
{{pp-semi-vandalism}}
<!-- Protection templates as small icons -->
{{pp-dispute|small=yes}}
{{pp-office|small=yes}}
{{pp-move|small=yes}}
{{pp-protected|small=yes}}
{{pp-template|small=yes}}
{{pp-usertalk|small=yes}}
{{pp-vandalism|small=yes}}
{{pp-semi-protected|small=yes}}
{{pp-semi-sock|small=yes}}
{{pp-semi-spambot|small=yes}}
{{pp-semi-template|small=yes}}
{{pp-semi-usertalk|small=yes}}
{{pp-semi-vandalism|small=yes}}
<!-- End protection templates, stop deleting, keep next line -->
}}
<!-- Text for all pages goes here -->
{{documentation}}
<!-- Please add this template's categories to the /doc subpage - thanks! -->
</noinclude>

Technical details sửa

If there is an accompanying "/testcases" page this template will detect that and show a link to the /testcases page.

This template categorises /sandbox pages into Category:Template sandboxes. If you don't want a page to be categorised then use the template like this:

{{Lưu ý chỗ thử bản mẫu|category=}}

If you want to demonstrate the template on say Wikipedia:Template messages/Template namespace then you need to feed the subpage-name to make it show and feed an empty category parameter so it doesn't categorise the page. Like this:

{{Lưu ý chỗ thử bản mẫu|subpage-name=Template namespace|category=}}

Xem thêm sửa