Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 2.08 KB

LJ-301-03.md

File metadata and controls

32 lines (23 loc) · 2.08 KB

#Learning Journal December 11, 2017 Recently I've been exposed to handle bars and gained some experience using expressions in our lab but still dont have a concrete grasp of it.

http://handlebarsjs.com/ the website has been really useful walking me through the todos in lab. Here are a few things I haven taken from handelbars... in the html, within tags, I can create variable like things known as "handlebar expressions which look like this...

{{title}}

all expressions must be placed within script tags like so... <script id="myTemplate" type="text/x-handlebars-template">

  <section id="articles">
    <article data-author="{{author}}" data-category="{{category}}">
      <header>
        <h1>{{title}}</h1>      <-----expression "title" notice how it isnt at the end of </body> tag like we're used to
    </article>
  </section>
</script>

You have to implent cdn sources into script tags in the html page before all other scripts. The cdn script looks something like... <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.11/handlebars.js"></script>

The whole point of handlebar expressions is to dynamically create content for the html which makes code much more clean and less clustered. Below is an example of dynamically creating content for our expression "title" to display "my new post" var context = {title: "My New Post"};

to make things even more efficient, we can create content for multiple expressions in the same variable and same line of code like so.. var context = {title: "My New Post", body: "This is my first post!"};

There is so much more that I can't remember all at once but if i ever need a resource with great examples and simple/short explanations, I know I can always resort to http://handlebarsjs.com/

I learned about regex this week which is probably my favorite tool given to us so far. It's easy to understand, has live text editor, display, source that describes what the code is used for and a code generator in multiple languages to easy implement into any function. regex101 is forever book marked in my borwser.