<commit_before># static_content

static_content provides an easy way of defining static content in your application.

## Installation

Add this line to your application's Gemfile:

    gem 'static_content'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install static_content

After install the gem, you just need run the install generator:

    $ rails g static_content:install

## Usage

### Creating content

The content we create can be normal text or a markdown. Let`s see the way we can create a content.

#### Standard Way

You can create as a normal model with:

    Content.create({slug: :about_title, text: "My awesome about page"}, as: :admin)

special attention to the `as: :admin`, the fields is only acessible to `admin`.

This is intended to be used with admin panels such as Typus or ActiveAdmin.

#### The better way

The better way is to use the `Content.from_slug` like:

    Content.from_slug(:about_title, default: "My awesome about page")

as this uses `find_or_initialize`, if is a new `slug` its create, if a old one its only return the value not raising a error.

So you can use this on a seed for example to create the default things.

### Showing content

#### content

Show your content as html, in your view, just add:

```erb
<%= c :about_title, default: "My awesome about page" %>
```

Please note that a `default` option is required. If it hasn't been created, it will be created upon the first request.

#### raw content

Show your raw content, in your view, just add:

```erb
<%= rc :about_title, default: "My awesome about page" %>
```

Please note that a `default` option is required. If it hasn't been created, it will be created upon the first request.

## Warning
<commit_msg>showing markdown sample<commit_after># static_content

static_content provides an easy way of defining static content in your application.

## Installation

Add this line to your application's Gemfile:

    gem 'static_content'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install static_content

After install the gem, you just need run the install generator:

    $ rails g static_content:install

## Usage

### Creating content

The content we create can be normal text or a markdown. Let`s see the way we can create a content.

#### Standard Way

You can create as a normal model with:

    Content.create({slug: :about_title, text: "My awesome about page"}, as: :admin)

special attention to the `as: :admin`, the fields is only acessible to `admin`.

This is intended to be used with admin panels such as Typus or ActiveAdmin.

#### The better way

The better way is to use the `Content.from_slug` like:

    Content.from_slug(:about_title, default: "My awesome about page")

as this uses `find_or_initialize`, if is a new `slug` its create, if a old one its only return the value not raising a error.

So you can use this on a seed for example to create the default things.

### Showing content

#### content

Show your content as html converted from markdown, in your view, just add:

```
<%= c :about_title, default: "# My awesome about page" %>
```

to be converted into

```
<h1>My awesome about page</h1>
```

Please note that a `default` option is required. If it hasn't been created, it will be created upon the first request.

#### raw content

Show your raw content, in your view, just add:

```
<%= rc :about_title, default: "# My awesome about page" %>
```

no change the value as

```
# My awesome about page
```

Please note that a `default` option is required. If it hasn't been created, it will be created upon the first request.

## Warning

{'fraction_non_alphanumeric': 0.0837234921509226, 'fraction_numerical': 0.000550812448361333, 'mean_word_length': 3.9685362517099865, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2030997', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1014, 'n_words': 538}