Case
Text in snake_case, camelCase, PascalCase, kebab-case, CONSTANT_CASE, Title Case and Sentence case: column names as API keys and labels.
Version 1.0.0 · 6 functions · 1 crate
Functions
What use case.qwer gives a program, with the types Quillo sees. To take only some, or under other names: use case_snake, case_camel from case (Quillo 0.6).
case_snake(text: str) → strtext in snake_case: "Hello World" and "helloWorld" are both "hello_world".
case_camel(text: str, upper: bool) → strtext in camelCase ("helloWorld"), or PascalCase ("HelloWorld") when upper is true.
case_kebab(text: str) → strtext in kebab-case, for addresses and CSS classes: "Hello World" is "hello-world".
case_constant(text: str) → strtext in SCREAMING_SNAKE_CASE, for environment variables and constants.
case_title(text: str) → strtext in Title Case, each word with a capital: "user_first_name" is "User First Name".
case_sentence(text: str) → strtext in Sentence case: the words split as for the others, the first with a capital, the rest lower case.
Get it
$ quillo install case # case.qwer into this folder$ quillo install case --example # and its example, case.qweOr with curl:
$ curl -O https://quillolang.org/plugins/files/case.qwer$ curl -O https://quillolang.org/plugins/files/case.qweThen, in your program, all of it or only what you call:
use case.qweruse case_snake, case_camel from case // Quillo 0.6: only theseIt uses this crate, which cargo fetches the first time the plugin is built:
heck = "0.5"Example
// Column names from a spreadsheet as API keys, labels and constants.//// quillo run case.qwe then open http://localhost:8080/columnsuse "case.qwer"let columns = ["First Name", "lastName", "date-of-birth", "HTTPStatus code"]route GET /columns = columns | map((c) => { column: c, key: case_snake(c), json: case_camel(c, false), type: case_camel(c, true), css: case_kebab(c), env: case_constant(c), label: case_title(c), sentence: case_sentence(c),})route GET /case ? { text: str } = { snake: case_snake(text), camel: case_camel(text, false), kebab: case_kebab(text), title: case_title(text), sentence: case_sentence(text) }$ quillo run case.qwe$ curl 'localhost:8080/columns'$ curl 'localhost:8080/case?text=user_firstName'Source
//! Text in every case programmers and writers use: snake_case, camelCase, kebab-case, Title Case, Sentence case.//! version: 1.0.0//!//! [dependencies]//! heck = "0.5"use heck::{ToKebabCase, ToLowerCamelCase, ToShoutySnakeCase, ToSnakeCase, ToTitleCase, ToUpperCamelCase};/// `text` in snake_case: "Hello World" and "helloWorld" are both "hello_world".pub fn case_snake(text: &str) -> String { text.to_snake_case()}/// `text` in camelCase ("helloWorld"), or PascalCase ("HelloWorld") when `upper` is true.pub fn case_camel(text: &str, upper: bool) -> String { if upper { text.to_upper_camel_case() } else { text.to_lower_camel_case() }}/// `text` in kebab-case, for addresses and CSS classes: "Hello World" is "hello-world".pub fn case_kebab(text: &str) -> String { text.to_kebab_case()}/// `text` in SCREAMING_SNAKE_CASE, for environment variables and constants.pub fn case_constant(text: &str) -> String { text.to_shouty_snake_case()}/// `text` in Title Case, each word with a capital: "user_first_name" is "User First Name".pub fn case_title(text: &str) -> String { text.to_title_case()}/// `text` in Sentence case: the words split as for the others, the first with a capital, the rest lower case.pub fn case_sentence(text: &str) -> String { let words = text.to_snake_case().replace('_', " "); let mut c = words.chars(); match c.next() { Some(f) => f.to_uppercase().collect::<String>() + c.as_str(), None => String::new(), }}Related
humanize.qwer · 1.0.0Durations, file sizes and relative times as people write them and back: 2h 30m, 1.5 GB, 2 GiB, 3 days ago, in 2 hours.7 views · 11 downloadsInflection inflect.qwer · 1.0.0English words in the right form for counts and labels: plurals and singulars, 3 items, ordinals such as 1st and 22nd, and a or an by how a word sounds.6 views · 7 downloadsJapanese kana kana.qwer · 1.0.0Japanese kana: romaji typed as hiragana or katakana, kana written in Hepburn romaji, hiragana and katakana each to the other, half-width katakana from bank and till systems made full-width, and which scripts a text uses.6 views · 10 downloadsProfanity filter profanity.qwer · 1.0.0Offensive words found and masked in comments, usernames and chat, with l33t spellings and spaced-out letters caught, and a severity per kind for moderation queues.8 views · 8 downloadsSpam filter spam_filter.qwer · 1.0.0A spam filter that learns from your own messages: naive Bayes trained on what users mark, kept in a file, scoring comments and forms from 0 to 1.7 views · 7 downloadsSpellcheck spellcheck.qwer · 1.0.0Spelling checked against a word list you load, in any language: unknown words found with their places, suggestions ranked by closeness and frequency (SymSpell's method), text corrected for "did you mean", and your own words added.7 views · 8 downloadsThread 0 posts
On Case: questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.