Skip to content

Support for .astro file #6

@SebinSong

Description

@SebinSong

Problem

A .astro file is a component file used in the Astro web framework.
Currently this is not recognised by strings utility but would be helpful if it this is supported, for a project like groupincome.org that uses this framework to build the website.

There is one thing to note about .astro file regarding curly braces({}). .astro file uses JSX-like syntax to inject Javascript expressions into its HTML template and uses curly braces for it. For example:

---
const name = "Astro";
---

<div>
  <h1>Hello {name}!</h1>  <!-- Outputs <h1>Hello Astro!</h1> -->
</div>

Or for specifying html attributes like:

---
const name = "Astro";
---
<h1 class={name}>Attribute expressions are supported</h1>

This means if {} is used for variable replacements like below i18n.vue usage:

i18n(:args='{ name: chatRoomAttributes.name, ...LTags("strong") }') Yes, I want to {strong_}delete {name} permanently{_strong}.

This will results in a compile error if used in .astro file.

Solution

  • Making the utility recognise .astro file as well.
  • Unless there is a better idea, could the pipe symbol | be used for variable replacements too? For example, .astro version of the above i18n example would be like this:
i18n(args={{ name: chatRoomAttributes.name, ...LTags("strong") }}) Yes, I want to |strong_|delete |name| permanently|_strong|.

This is my own idea for the solution but if there is a better alternative, please go ahead with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions