Giter VIP home page Giter VIP logo

ftrybe / vue-typescript-files Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 1.59 MB

Welcome to the VSCode Template Injector Plugin, a powerful extension designed to enhance your development workflow within Visual Studio Code. This plugin adds customizable actions to the context menu in the VSCode file explorer, specifically when right-clicking on folders.

License: MIT License

TypeScript 71.71% CSS 5.66% HTML 3.11% JavaScript 19.53%
vue vscode-plugin vue-typescript

vue-typescript-files's Introduction

vue-typescript-files 说明

预览

image

右击文件夹添加组件(right-click folder)

基本功能

组件提供资源管理器右击菜单扩展。对应的模版文件需要自己编写。

目前提供7个扩展按钮,如下:

  1. 生成组件模版
  2. 生成vuex模版
  3. 生成指令模版
  4. 生成组件声明模版
  5. 生成类文件模版
  6. 生成枚举模版
  7. 生成接口模版

如果需要的扩展按钮不为以上7种,可以直接进入插件包管理目录,修改package.json中对应的按钮显示名称以实现自定义扩展。

创建组件命令行参数说明

空格分隔符后除了带$符号的的参数都可以在模版中使用 {{args}}获取.

当使用带有$符号的参数时,将对模版名称进行拼接查找。如: 如果选择创建Class,文件名输入 User $dialog 那么将会寻找在定义模版路径下的 class_dialog文件进行渲染。

输入 test $dialog -e username=name&password=admin123 -url http://localhost:3000/api/username

配置说明

需要添加全局组件前后缀请选择

文件 => 首选项 => 设置 => 扩展 => vue-typescript-files

添加组件自定义标签模板,请配置模版路径。前往git参考复制模版到指定路径下。

模版文件加载说明

  1. 在当前工作区下添加.vue-typescript-files目录,渲染模版将优先寻找当前目录下的模版
  2. 配置vue-typescript-files.template.path为指定目录,在.vue-typescript-files目录下找不到文件时将使用当前目录下的模版
  3. 插件自带的模版最后获取

自定义模版命名

对于自定义模版有严格的命名要求。文件必须以指定模版类型为前缀,以.tmpl结尾。支持的类型如下:

  1. class => class.tmpl
  2. component => component.tmpl
  3. declare => declare.tmpl
  4. directive => directive.tmpl
  5. enum => enum.tmpl
  6. interface => interface.tmpl
  7. vuex => vuex: vuex.tmpl

该插件使用 handlebars进行模版渲染,相关语法自行进行了解。

自定义模版参数

设置enableExtendParams参数为true后,将在每次执行渲染前获取当前工作区.vue-typescript-files目录下的params.json文件。

{
  "table": {
    "type": "api",
    "value": "http://localhost:8086/api/tables",
    "scope": ["class"],
    "headers": {
      "Authorization": "bearer xxxx"
    }
  },
  "version": "1.0.0",
  "js": {
      "type": "js",
      "value": ".vue-typescript-files/hello-word.js",
      "scope": ["class"]
  },
  "json": {
    "type": "json",
    "value": ".vue-typescript-files/test.json"
  }
}

tmpl文件时渲染前将根据type调用不同类型的操作,返回的结果集将会以key-value形式存储在 extend变量中.如以上params.json文件,在成功获取数据后,通过以下方式调用值。

export class {{dynamicName}} {
  const version = {{extend.version}};

  {{#each extend.tables  as | tables |}}
    {{tables.name}}
  {{/each}}
}

Additional Support

  • JetBrains - Thanks a lot for supporting vue-typescript-files project. image

vue-typescript-files's People

Contributors

ftrybe avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

philipxiaoxi

vue-typescript-files's Issues

hey , guy , i need you

I need anthor template like “ pug ” ?

And when i set the CSS preprocessor to stylus or scss/sass it doesn't work~~~

Command-based template rendering

Command-based template rendering: We plan to implement a feature that allows users to render template content directly at the current cursor position using specific commands. This will provide even more flexibility and speed in code generation and insertion.

File Initializer with Template Preview

Provides a preview panel for real-time template rendering。allowing users to visualize component template code based on the configured rendering parameters. This preview capability enhances the development workflow by offering immediate feedback on template modifications and parameter adjustments.


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.