<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ পিএইচপি ভেরিয়েবল Echo এবং প্রিন্ট স্ট্যাটমেন্ট - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ পিএইচপি ভেরিয়েবল Echo এবং প্রিন্ট স্ট্যাটমেন্ট - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Wed, 01 Jul 2026 22:50:20 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/echo/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to setup a nested HTML template in the Go Echo web framework ]]>
                </title>
                <description>
                    <![CDATA[ By Ying Kit Yuen Echo is a lightweight but complete web framework in Go for building RESTful APIs. It is fast and includes a bunch of middleware for handling the whole HTTP request-response cycle. For the rendering part, it works with any template en... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-setup-a-nested-html-template-in-the-go-echo-web-framework-670f16244bb4/</link>
                <guid isPermaLink="false">66c354a3df235c0b59e2531e</guid>
                
                    <category>
                        <![CDATA[ পিএইচপি ভেরিয়েবল Echo এবং প্রিন্ট স্ট্যাটমেন্ট ]]>
                    </category>
                
                    <category>
                        <![CDATA[ golang ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 05 Dec 2018 23:01:58 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*i1ZfgPCFQ95TeWWMiLa8wA.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Ying Kit Yuen</p>
<p><a target="_blank" href="https://echo.labstack.com/">Echo</a> is a lightweight but complete web framework in <a target="_blank" href="https://golang.org/">Go</a> for building RESTful APIs. It is fast and includes a bunch of middleware for handling the whole HTTP request-response cycle. For the rendering part, it works with any template engine, but I use the standard <a target="_blank" href="https://godoc.org/html/template">html/template</a> package for the purpose of simplicity. By the end of this article, we will have a nested template <a target="_blank" href="https://echo.labstack.com/">Echo</a> project setup.</p>
<p>If you already have an idea on how <a target="_blank" href="https://echo.labstack.com/">Echo</a> works, jump to the <a class="post-section-overview" href="#b8ff">Using a nested template section</a>.</p>
<h3 id="heading-a-basic-echo-project-setup">A basic Echo project setup</h3>
<h4 id="heading-create-the-project-folder-under-the-proper-gopath">Create the project folder under the proper $GOPATH</h4>
<p>The complete project code is hosted on <a target="_blank" href="https://gitlab.com/ykyuen/golang-echo-template-example">Gitlab</a>. First we’ll create the project folder here: <em>$GOPATH/src/gitlab.com/ykyuen/golang-echo-template-example</em>.</p>
<h4 id="heading-create-the-maingo">Create the main.go</h4>
<p>Inside the newly created folder, let’s just copy the hello world example from the <a target="_blank" href="https://echo.labstack.com/">Echo</a> official site and create the <em>main.go</em>.</p>
<p><strong>main.go</strong></p>
<h4 id="heading-download-the-echo-package-using-dep">Download the Echo package using dep</h4>
<p>Simply run <strong>dep init</strong> if <a target="_blank" href="https://github.com/golang/dep">dep</a> is installed. You can refer to this post for more information about dep: <a target="_blank" href="https://blog.boatswain.io/post/manage-go-dependencies-using-dep/">Manage Go dependencies using dep</a>.</p>
<p>Or run <strong>go get github.com/labstack/echo</strong> to download the <a target="_blank" href="https://echo.labstack.com/">Echo</a> package in <em>$GOPATH</em>.</p>
<h4 id="heading-run-the-hello-world">Run the hello world</h4>
<p>Start the application by typing <strong>go run main.go</strong> and then visit <a target="_blank" href="http://localhost:1323">http://localhost:1323</a> through the browser or the <strong>curl</strong> command.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*aExSnI6KPWva_VRT2-2wGg.jpeg" alt="Image" width="800" height="326" loading="lazy">
<em>Start the Echo server.</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*j-u3NXp7_u7PTVUiYVGwFA.jpeg" alt="Image" width="800" height="95" loading="lazy">
<em>Send a request and get the hello world.</em></p>
<h3 id="heading-return-a-json-response">Return a JSON response</h3>
<p>When building a RESTful API, it is more likely that the client wants to receive a JSON response instead of a string. Let’s write some <a target="_blank" href="https://golang.org/">Go</a> code in <em>main.go</em>.</p>
<p><strong>main.go</strong></p>
<h3 id="heading-return-an-html">Return an HTML</h3>
<p>Similar to returning a JSON object, we just need to call another method in the <strong>return</strong> statement.</p>
<p><strong>main.go</strong></p>
<p>The above are just two simple examples. <a target="_blank" href="https://echo.labstack.com/">Echo</a> has a few more convenient ways to return JSON and HTML. For details please refer to the <a target="_blank" href="https://echo.labstack.com/guide/response">documentation</a>.</p>
<h4 id="heading-render-html-using-template-engine">Render HTML using template engine</h4>
<p>As mentioned at the very beginning, we could implement a template engine when returning the HTTP response. But before that, let’s restructure the project as follows:</p>
<p><strong>main.go</strong></p>
<p>In this <em>main.go</em>, we define a type called <strong>TemplateRegistry</strong> and implement the <strong>Renderer</strong> interface. A <strong>Renderer</strong> is a simple interface which wraps the <strong>Render()</strong> function. Inside a <strong>TemplateRegistry</strong> instance, it has a <strong>templates</strong> field containing all the templates needed for the <a target="_blank" href="https://echo.labstack.com/">Echo</a> server to render the html response, and this is configured in the <strong>main()</strong> flow.</p>
<p>On the other hand, we define the <strong>HomeHandler</strong> in order to keep the logic in a separate file.</p>
<p><strong>handler/home_handler.go</strong></p>
<p>When the <strong>c.Render()</strong> is invoked, it executes the template which is already set in our <strong>TemplateRegistry</strong> instance as stated in <strong>main.go</strong>. The three parameters are:</p>
<ol>
<li>HTTP response code</li>
<li>The template name</li>
<li>The data object which could be used in the template</li>
</ol>
<p><strong>view/home.html</strong></p>
<p>This above template is named <strong>home.html</strong> as stated in the <strong>define</strong> statement. It can read the <strong>name</strong> and <strong>msg</strong> strings from <strong>c.Render()</strong> for the <strong>&lt;tit</strong>le&gt;<strong>; an</strong>d </p><h1 id="heading-tags"> tags.<p></p>
</h1><h4 id="heading-using-nested-template">Using nested template</h4>
<p>In the above setup, every HTML template has a complete set of HTML code and many of them are duplicated. Using nested templates makes it easier to maintain the project.</p>
<p>Originally the <strong>templates</strong> field in the <strong>TemplateRegistry</strong> contained all the templates files. In the new setup, we made it into an array field and each array item is a single set of template files for a particular HTML page.</p>
<p>We add a few files to the project and it should look like this:</p>
<p>The code below is based on this <a target="_blank" href="https://gist.github.com/rand99/808e6e9702c00ce64803d94abff65678">gist</a> created by <a target="_blank" href="https://gist.github.com/rand99">rand99</a>.</p>
<p><strong>main.go</strong></p>
<p>We add a new route <strong>/about</strong> which is handled by an <strong>AboutHandler.</strong> As you can see from the above lines <a target="_blank" href="https://gist.github.com/ykyuen/a8bcf35a338f398ddfe61275ac91e439#file-main-go-L34-L36">34-36</a>, the <strong>templates</strong> array contains different sets of template files for different HTML pages. The <strong>Render()</strong> takes the <strong>name</strong> parameter as the <strong>templates</strong> array key so it can execute the correct template set.</p>
<p><strong>view/base.html</strong></p>
<p>The <strong>template</strong> statement tells the template engine that it should look for the <strong>{{title}}</strong> and <strong>{{body}}</strong> definitions in the template set, and they are defined in the <strong>home.html</strong> as well as <strong>about.html</strong>.</p>
<p><strong>view/about.html</strong></p>
<p>And here is the <strong>AboutHanlder</strong> which has no big difference from the <strong>HomeHandler</strong>.</p>
<p><strong>handler/about_handler.go</strong></p>
<h3 id="heading-summary">Summary</h3>
<p>This is just a basic example implementing nested templates using the <a target="_blank" href="https://golang.org/">Go</a> standard <a target="_blank" href="https://godoc.org/html/template">html/template</a> library in <a target="_blank" href="https://echo.labstack.com/">Echo</a>. With proper setup, we could develop a more customized and convenient pattern for <a target="_blank" href="https://echo.labstack.com/">Echo</a> or even make it work with any other template engines.</p>
<p>The complete example can be found on <a target="_blank" href="https://gitlab.com/ykyuen/golang-echo-template-example">gitlab.com</a>.</p>
<p>— Originally posted on <a target="_blank" href="https://blog.boatswain.io/post/setup-nested-html-template-in-go-echo-web-framework/">Boatswain Blog</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Introducing the freeCodeCamp Coding Trivia Quiz on Amazon Alexa ]]>
                </title>
                <description>
                    <![CDATA[ Now you can learn coding concepts hands-free using an Amazon Echo. freeCodeCamp.org contributor David Jolliffe created a quiz game with questions on JavaScript, CSS, networking, and computer science. If you have an Amazon Echo nearby, you can play th... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/amazon-alexa-javascript-css-programming-quiz/</link>
                <guid isPermaLink="false">66b8d22bf8e5d39507c4c0d1</guid>
                
                    <category>
                        <![CDATA[ Amazon ]]>
                    </category>
                
                    <category>
                        <![CDATA[ পিএইচপি ভেরিয়েবল Echo এবং প্রিন্ট স্ট্যাটমেন্ট ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Quincy Larson ]]>
                </dc:creator>
                <pubDate>Thu, 13 Sep 2018 20:25:46 +0000</pubDate>
                <media:content url="https://img.youtube.com/vi/IFAmuQgjMK0/maxresdefault.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Now you can learn coding concepts hands-free using an Amazon Echo.</p>
<p>freeCodeCamp.org contributor <a target="_blank" href="https://github.com/OcelotDive">David Jolliffe</a> created a quiz game with questions on JavaScript, CSS, networking, and computer science.</p>
<p>If you have an Amazon Echo nearby, you can play the game right now by saying: "Alexa, start the free code camp quiz."</p>
<p>The entire project, along with it's ~100 questions, is <a target="_blank" href="https://github.com/freeCodeCamp/FreeCodeCampTriviaQuiz">open source and on GitHub</a>. We would welcome additional questions. Open a pull request adding your new question to the codebase, or just open a GitHub issue with the question if you're in a hurry.</p>
<p>Here's a video of me and my 11-month-old son Quentin demonstrating the Alexa skill. You can watch the video on <a target="_blank" href="https://www.youtube.com/watch?v=IFAmuQgjMK0">the freeCodeCamp.org YouTube channel</a> (3 minute watch).‌</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
