Skip to content

A simple replacement for template strings, template literals, tagged template literals for ES3

License

Notifications You must be signed in to change notification settings

VSADX/template-literals-for-es3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

template-literals-for-es3

this repo adds a function to tag-params library by WebReflections.
this library uses tagParams as the name in JS.

function MyComponent() {
  
  var year = 1999
  var now = new Date().getFullYear()
  
  return tagParams.multiline(function(fn){/*!
    <div>
      <h1> Hi guys, it's ${year} </h1>
      <br><br>
      <p>This JavaScript worked <i>${now - year}</i> years ago.</p>
    </div>
    */
    return eval(fn)
  })
}

How does it work?

  1. JS keeps comments in code.
  2. /*! tells multiline to string this comment.
  3. return eval can detect the variables for you!
  4. tag-params library finds ${ to } then it is evalled.

About

A simple replacement for template strings, template literals, tagged template literals for ES3

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%