Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📚 Doc: Add detailed documentation for the templates guide #3113

Merged
merged 6 commits into from
Aug 28, 2024

Conversation

grivera64
Copy link
Member

@grivera64 grivera64 commented Aug 28, 2024

Description

This issue proposes to provide more snippets of ways to use templates in Go Fiber’s templates guide.

Fixes #3108

Changes introduced

  • Documentation Update: Re-order Templates guide headings
  • Documentation Update: Reword details on templates usage and custom engines
  • Documentation Update: Add details on advanced usage of templates
  • Examples: Provide full example of using the html template engine.

Type of change

  • Documentation update (changes to documentation)

Checklist

Before you submit your pull request, please make sure you meet these requirements:

  • Followed the inspiration of the Express.js framework for new functionalities, making them similar in usage.
  • Conducted a self-review of the code and provided comments for complex or critical parts.
  • Updated the documentation in the /docs/ directory for Fiber's documentation.
  • Added or updated unit tests to validate the effectiveness of the changes or new features.
  • Ensured that new and existing unit tests pass locally with the changes.
  • Verified that any new dependencies are essential and have been agreed upon by the maintainers/community.
  • Aimed for optimal performance with minimal allocations in the new code.
  • Provided benchmarks for the new code to analyze and improve upon.

Copy link
Contributor

coderabbitai bot commented Aug 28, 2024

Warning

Rate limit exceeded

@ReneWerner87 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 26 minutes and 38 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 5e9930f and fc370f3.

Walkthrough

The documentation for template engines in the Fiber framework has been significantly enhanced. The section has been restructured to provide clearer guidance on integrating custom template engines, with detailed examples and new subsections covering supported engines, rendering templates, and advanced features.

Changes

File Path Change Summary
docs/guide/templates.md Restructured section to "Template Engines," added examples, new subsections on supported engines and rendering, and detailed the Views interface methods. Expanded on advanced templating features like AddFunc and AddFuncMap.

Assessment against linked issues

Objective Addressed Explanation
Add detailed documentation for the templates guide (#3108)
Provide snippets for rendering dynamic HTML and iterating (#3108)

Poem

In the land of Fiber, changes bloom,
Templates now shine, dispelling the gloom.
With examples galore, and engines to share,
Custom functions added, for all who dare.
Hop in, dear coder, let creativity flow,
In the garden of templates, watch your ideas grow! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ReneWerner87 ReneWerner87 linked an issue Aug 28, 2024 that may be closed by this pull request
3 tasks
- Add link to https://github.com/gofiber/template in Templates Guide
- Fix typo: missing period in info block about ctx.Render()
@grivera64 grivera64 marked this pull request as ready for review August 28, 2024 06:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
docs/guide/templates.md (1)

11-11: Enhance introductory statement for clarity.

Consider expanding this introduction to explicitly mention the types of templates (e.g., HTML, Pug) supported and typical use cases, which could help newcomers understand the context better.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 87bb93e and 5e9930f.

Files selected for processing (1)
  • docs/guide/templates.md (4 hunks)
Additional context used
Markdownlint
docs/guide/templates.md

120-120: Expected: asterisk; Actual: dash
Unordered list style

(MD004, ul-style)


166-166: Expected: asterisk; Actual: dash
Unordered list style

(MD004, ul-style)


214-214: Expected: asterisk; Actual: dash
Unordered list style

(MD004, ul-style)

Additional comments not posted (5)
docs/guide/templates.md (5)

13-29: Well-structured introduction to Template Engines.

This section clearly explains how to initialize a Fiber application with a custom template engine. The configuration options are well-detailed, enhancing the understanding of ViewsLayout and PassLocalsToViews.


51-57: Detailed explanation of the Views interface.

The methods Load() and Render() are well-explained, providing clarity on their usage within the Fiber framework. This is crucial for developers implementing custom template engines.


67-91: Clear example of rendering templates.

The example provided is straightforward and demonstrates the practical use of the ctx.Render() function effectively. This aligns well with the PR's objective to enhance usability and clarity.


Line range hint 216-272: Comprehensive full example section.

This section effectively demonstrates the use of the Go Fiber template engine with detailed code snippets. It provides a practical, real-world example that will greatly aid users in understanding how to implement templates in their projects.


32-45: Comprehensive list of supported engines.

The links provided for each template engine are helpful. However, ensure all links are up-to-date and lead to the correct resources as external links can often become outdated.

Verification successful

All links are active and correct.

The verification script confirmed that all external links in the docs/guide/templates.md file are active and lead to the correct resources. No broken links were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that all external links are active and correct.

for url in $(grep -oP '(?<=\().*?(?=\))' docs/guide/templates.md | grep 'https'); do
  if ! curl -o /dev/null -sIf "$url"; then
    echo "Broken link: $url"
  fi
done

Length of output: 1680

docs/guide/templates.md Outdated Show resolved Hide resolved
@grivera64 grivera64 requested a review from ReneWerner87 August 28, 2024 06:11
@ReneWerner87 ReneWerner87 merged commit ca935c3 into gofiber:v2 Aug 28, 2024
1 check passed
thylong pushed a commit to thylong/fiber that referenced this pull request Dec 11, 2024
* Organize and reword templates guide

* Add full example to templates guide

* Add advanced templating section to template guide

* Add template repo link and fix typo in Templates guide

- Add link to https://github.com/gofiber/template in Templates Guide
- Fix typo: missing period in info block about ctx.Render()

* Update docs/guide/templates.md

* Update docs/guide/templates.md

---------

Co-authored-by: RW <rene@gofiber.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📚 Doc: Add detailed documentation for the templates guide
2 participants