A stylesheet language written in TypeScript that compiles to CSS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

let.ts 749B

123456789101112131415161718192021222324
  1. import * as AST from '../ast';
  2. import Env, { EnvError } from '../env';
  3. export class Let {
  4. public bindings: AST.Binding[];
  5. public children: AST.Node[];
  6. public constructor(bindings: AST.Binding[], children: AST.Node[]) {
  7. this.bindings = bindings;
  8. this.children = children;
  9. }
  10. public compile(env: Env, opts: AST.Opts): string | EnvError {
  11. this.bindings.forEach((binding) => {
  12. env.set(binding.identifier.name.value, binding.value);
  13. });
  14. const children = this.children.map((child) => child.compile(env, opts));
  15. const childrenError = children.find((node) => node instanceof EnvError);
  16. if (childrenError instanceof EnvError) return childrenError;
  17. return children.join(opts.prettyPrint ? '\n' : '');
  18. }
  19. }