tag template

by Artem

JavaScript

'use strict';

var a = 5;
var b = 10;

function tag(strings, ...values) {
  let cssText = '';

  return (props) => {
    strings.forEach((s, i) => {
      cssText += s;
      if (values[i]) {
        cssText += values[i](props);
      }
    });
    console.log('????? ', cssText)
    return 1;
  };
}

var c = tag `
background-color: red;
margin: ${props => props.margin};
color: white;
position: ${props => props.position};
`;
// "Bazinga!"

console.log(c({
  margin: 2,
  position: 'absolute'
}));