Home » vue » Does JavaScript(ES2015) have preprocessor support for omit braces?

Does JavaScript(ES2015) have preprocessor support for omit braces?

Posted by: admin November 26, 2021 Leave a comment

Questions:

Does JavaScript have preprocessor support for omit braces like in Stylus and Jade?

For example:

<style lang="stylus" scoped>
div
  background-color red
p
  color blue
</style>

<script>
import something from './something';

export default {
  vuex: {
    getters: {
      todos: state => state.todos;
    }
  }
};
</script>

<template lang="jade">
div
  p Hello World!
</template>

I want to write ES6 code that just like:

<script lang="?">
import something from './something'

export default
  vuex:
    getters:
      todos: state => state.todos
</scrip>
Answers:

I think you’re looking for something like CoffeeScript. It’s a preprocessor for JavaScript that is white space sensitive, like Jade, so you often do not need a lot of punctuation.

###

JavaScript/ECMAScript (as a language) does not have any preprocessor support at all, because it doesn’t need compilation or preprocessing – it’s an interpreted scripting language.

You can however write a custom preprocessor that does whatever you want and apply it manually to your script files.